You have 3 piles — of size A B & C — and you can take a triplet from them as long as you take from more than one. So what is the maximum number of triplets?

e.g.

Piles : take ,, and .

N.B. we have left over which can’t be used.

I must admit, when I began to work on this, I took the wrong track. I tried to iterate over the input, pulling out triplets in a greedy fashion. This pile is biggest so take from that. But do I take 2 plus 1 from the next? Or take from all? And because the inputs are so large, how many triplets do I pull at once? How do I guarantee I’m making the best next move? etc.

But no, we aren’t calculating a list of triplets, just *how many*. So the question becomes: which inputs *can’t* be used? Then everything else *can* be, it doesn’t matter *how exactly*.

If > , we can’t use anything above . And the same for B & C. So, after these are chopped off, we get the following: