Editorial for COCI '10 Contest 5 #1 Gljive


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.

Notice that distance between the numbers X and 100 is equal to:

  • X-100, if X is greater than 100
  • 100-X, otherwise

We add numbers one by one starting from the first. If the running sum becomes greater than 100, our solution is either the previous sum we had, or the current sum. We choose the sum closer to 100.

If the sum of all the numbers is not greater than 100, we output this sum.


Comments

There are no comments at the moment.