Help in Codeforces #446 A

Can anyone help me in understanding this problem Greed. It sounds simple but I don’t seem to get the logic. Also the editorials don’t have much

Hi, Let me rephrase the question.
You are given n cans, initial amount of cola present in it and also the capacity of each can.
We are asked that whether any 2 cans can put all cola in it?
So, we should pick the maximum and second maximum capacity cans, and check whether max1+max2 is greater than equal to all cola.
Feel free to ask any questions.

1 Like