JOSBEAK's blog

By JOSBEAK, history, 4 years ago, In English

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 .

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

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

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.