Advertisement
wrequiems

Untitled

Mar 18th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. def go():
  2.     n, k  = map(int, input().split(' '))
  3.     a = [int(i) for i in input().split(' ')]
  4.     d = {}
  5.     answer = 0
  6.     for x in a:
  7.         m = x % k
  8.         complement = k - m if m != 0 else 0
  9.         if complement in d:
  10.             answer += 2
  11.             d[complement].pop()
  12.             if len(d[complement]) == 0:
  13.                 d.pop(complement)
  14.         else:
  15.             d.setdefault(m, [])
  16.             d[m].append(None)
  17.     return answer
  18.  
  19. print(go())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement