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

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

Hello https://codeforces.com/contest/1392/problem/B I dont understand why my code fails? https://ideone.com/OvJGfP

Algo: if k is odd : then -=max from every element. if k is even: then dont do anything because the subtractions will eliminate each other like max-(max-x) = x

Thanks,

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

»
4 года назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

$$$k = 2$$$. input array: $$$[-199, 192]$$$

After first iteration, the array becomes: $$$[391, 0]$$$

After second iteration, $$$[0, 391]$$$

Hope you get the point.