solution

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!