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 1144. The Emperor's Riddle

solution
Posted by wangbicheng1 13 Nov 2015 09:22
Assume each general's gold a[1],a[2],...,a[m]
divide them into b[1]&c[1],b[2]&c[2],...,b[m]&c[m],and b[1]+c[1]=a[1],b[2]+c[2]=a[2],...
(b[i] can be any partition from a[i])
Then sort b from big to small, sort c from small to big.
We can prove that between b[1]+c[1],b[2]+c[2],...,b[m]+c[m], the biggest minus the smallest would not be worse than the previous one. Continuously do this and we'll get the answer.
This solution is developed by Wenbin Tang. Thanks to him!