Editorial for An Animal Contest 1 P2 - Alpaca Racing
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
Notice that is not necessary to solve the problem, as distance is constant for all racers. In this subtask, , meaning you can "eliminate" each alpaca with a higher speed than you by using your special power once. Therefore, simply count the number of alpacas that are faster or have the same speed as you and compare the result to .
Time Complexity:
Subtask 2
Here, we explain a simple approach. For every alpaca, it is necessary to lower its speed until it is slower than your alpaca. Simply keep on lowering each alpaca's speed while it is greater than and count the amount of times you do this in order to compare with .
Notice that this approach with no optimization may not pass cases where the difference between a certain and is large and is sufficiently small. To fix this, simply stop looping and incrementing when becomes greater than , as it is already known that it is impossible to win by this point.
Time Complexity:
Comments
good problem!
wsg
glorious king