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

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

Question Link:- https://codeforces.net/contest/1506/problem/D

My Solution:- https://codeforces.net/contest/1506/submission/111740871

Getting wrong answer on 2nd test case .

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

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

Consider the case when n=6 and a = [1,1,2,3,4,5]. As per your code d=4 and x=2, thus your output will be 2, which is surely wrong. Your solution considers only the combinations (1,2) and (1,3) and assumes that the remaining values can't be removed. But they can be, because we are left with 4 and 5 which can be paired together and removed. So the answer should be 0.