Problem link
Let's suppose that array is sorted. First of all, if , than the answer is — NO (because otherwise 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:
It's easy to see, that all numbers except will have at least one neighbor which is not smaller than itself. Complexity .
A solution in c++
0 Comments
If you have any doubts, Please let me know