Codeforces 1189B. Number Circle Codeforces Round #572 (Div. 2)


Problem link

Let's suppose that array is sorted. First of all, if anan1+an2, than the answer is — NO (because otherwise an is not smaller than sum of the neighbors). We claim, that in all other cases answer is — YES. One of the possible constructions (if the array is already sorted) is:
an2,an,an1,an4,an5,,a1
It's easy to see, that all numbers except an will have at least one neighbor which is not smaller than itself. Complexity O(nlog(n)).

A solution in c++


Post a Comment

0 Comments