XMORE's blog

By XMORE, history, 3 months ago, In English,

Could someone explains to me why the answer to the first testcase is -2 http://codeforces.com/contest/402/problem/D

 
 
 
 
  • Vote: I like it  
  • -5
  • Vote: I do not like it  

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

That is because the best you can do with the array is transform it to 1,5,17,5,5 in two operations. Now the beauty corresponding to each element is 0,-1,1,-1,-1. And hence the sum is -2.