Блог пользователя Hadras

Автор Hadras, история, 2 года назад, По-английски

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

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится

»
2 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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.