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)


Comments


  • -1
    AhmedAmineLoukil  commented on Sept. 1, 2021, 10:20 a.m. edited

    So the formula is ans=(ceil((N-S)/5))? And by the way, in the Constraints : 0 \le N, B, S, G \le 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, 1:24 p.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