Codeforces Round #446 (Div. 2) D

讨论版提供的一个思路,感觉挺好的

Yes, and it's easy to prove. Let's consider for convenience the permuted arrays a and b:

a1<a2<..<a(N-1)<aN
^   ^     ^      v
a2<a3<..<aN    >a1

If we take any subset that doesn't contain the last element, the sum on the lower side will definitely be bigger. So, we'd only have a problem with those that contain the last element. We need to balance a difference of aN — a1 with a subset of the values a[i + 1] — a[i] for 1 <= i < N. The nice part is that all those are positive and only if we choose them all will we be able to balance the differences (otherwise the total balance from the second part is still too small)

FST得很开心,233



原文地址:https://www.cnblogs.com/Drenight/p/8611220.html