-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathac20p2.py
37 lines (35 loc) · 1.04 KB
/
ac20p2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from sys import stdin
input = stdin.readline
number, moves = [int(x) for x in input().split()]
weights = {}
theWeight = [int(x) for x in input().split()]
for i in theWeight:
if i not in weights:
weights[i] = 1
else:
weights[i] += 1
for i in range(moves):
move, num = [int(x) for x in input().split()]
if move == 1:
if num not in weights:
continue
if num % 2 == 1:
if num // 2 not in weights:
weights[num // 2] = weights[num]
else:
weights[num // 2] += weights[num]
if num // 2 + 1 not in weights:
weights[num // 2 + 1] = weights[num]
else:
weights[num // 2 + 1] += weights[num]
else:
if num // 2 not in weights:
weights[num // 2] = weights[num] * 2
else:
weights[num // 2] += weights[num] * 2
weights[num] = 0
else:
if num in weights:
print(weights[num])
else:
print(0)