Test
commit
9a7ae9c957
|
@ -0,0 +1,26 @@
|
|||
from collections import defaultdict
|
||||
|
||||
# I
|
||||
N, M = map(int, input().split())
|
||||
cup = defaultdict(int)
|
||||
|
||||
for _ in range(N):
|
||||
x, s = map(int, input().split())
|
||||
cup[x] += s
|
||||
|
||||
# summa dalās ar M
|
||||
pairs = 0
|
||||
|
||||
for x in cup:
|
||||
if x >= M - x and cup[x] > 0:
|
||||
if x == M - x:
|
||||
pairs += cup[x] // 2
|
||||
cup[x] %= 2
|
||||
else:
|
||||
if M - x in cup:
|
||||
pairs += min(cup[x], cup[M - x])
|
||||
cup[x] -= min(cup[x], cup[M - x])
|
||||
cup[M - x] -= min(cup[x], cup[M - x])
|
||||
|
||||
|
||||
print(pairs)
|
Loading…
Reference in New Issue