Editorial for COCI '11 Contest 6 #1 Jack
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
is small enough to try out all the possible combinations of three cards. There are less than combinations. We can use three nested for-loops: first one to choose the first card we will take, second one to choose the second card, and third one to choose the final card.
In the inner loop, we check if the sum of the chosen cards is greater than . If it is, we continue to the next combination. If it's not, we check if this sum is greater than the best sum found so far and update that sum if it is. At the end, we simply output the largest sum found.
Comments