Comments

You can solve it with simple recursion. I missed a case and was not able to solve. see: https://mirror.codeforces.com/contest/1741/submission/175668100

how to solve E?

calculate prefix sum Solve for each i in prefix sum where pref[i] divides sum;

0

If you serach it on yt you can find: https://www.youtube.com/watch?v=lMIrJHjRjAY

it includes the n-k+1 element from the original array .. not the prefix sum because given last k prefix sums you can only find last k-1 elements. So the maximum number you can place in first n-k+1 positions is the element found for position n-k+2 or k-1th element from the last because we want to keep the original array sorted.

what's the maximum number you can place in the last n-k+1 elements it's the a(n-k+2) which you calculated. Now If the sum of last n-k+1 elements is greater that (n-k+1) * a(n-k+2), you would have to put at least one number greater than a(n-k+2), but then the array won't be sorted.

If your only concern is the header, get it from github and precompile it...afterwards it won't make a big difference if you use clang or gcc.

Bleach One Piece Haikyuu