Hadras's blog

By Hadras, history, 2 years ago, In English

why he made this condition in his code in this problem : https://codeforces.com/contest/1512/problem/E if(s — i >= 1LL * (len — 1) * len / 2 && len > 0) i am talking about s-i =>(len-1)*(len)/2 code : https://ideone.com/sPISxq

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

| Write comment?
»
2 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Because the sum of the remaining numbers can be at least (len-1)*len/2 (1+2+3+...+(len-1)). If this value plus i is bigger than s, it would be impossible to satisfy the condition after putting i to the region.