ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1777. Anindilyakwa

Solved it by simulation.
Posted by Mahilewets 21 Jun 2017 18:16
After we add new pile Z of stones if there is new pair of piles X and Y such that |X-Y| is minimal that either X=Z or Y=Z. So,  just add nee pile and recalculate new pair of piles such that the difference between stones count is minimal in O(n)  where n is tje number of piles present now.