Author: Error_Yuan
Hint
Solution
Author: _istil
Hint 1
Hint 2
Solution
Author: Error_Yuan
Hint
Tutorial
And, in the last round, it is everyone will pass his potato to the next person (if he can). Thus, according to the claim you can solve the problem by simulating the last round. Time complexity is $$$\mathcal{O}(n)$$$.



