Editorial for Olympic Scoring

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.

Author: qwertytown4life

It is always optimal for Canada to win gold and only gold medals as they increase Canada's score by the most points. Consider the difference between Canada's score and N, and calculate the number of gold medals needed to win. Note that this number may be 0.

Time Complexity: \mathcal{O}(1)


  • -2
    AhmedAmineLoukil  commented on Sept. 1, 2021, 6:20 a.m.

    So the formula is ans=(ceil((N-S)/5))? And by the way, in the Constraints : 0≤N,B,S,G≤10^18, 10^18 isn't a lot? How can a time limit of 0,5s work using large numbers!

    • 4
      DM__Oscar  commented on Sept. 1, 2021, 9:24 a.m.

      10^{18} is not really alot, it fits within a 64-bit signed integer

      moving a couple of these bits around is nothing for a cpu with billions of transistors