-
Notifications
You must be signed in to change notification settings - Fork 185
/
Copy pathb.py
executable file
·44 lines (43 loc) · 1.19 KB
/
b.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
38
39
40
41
42
43
44
#!/usr/bin/env python3
# https://codingcompetitions.withgoogle.com/codejam/round/0000000000051679/00000000001461c8
for _ in range(int(input())):
x = [None] * 20
s = set()
o = 0
e = None
while True:
d = int(input())
if d == -1:
import sys; sys.exit(0)
if d < 20:
print('{} 100'.format(d))
elif d < 90:
while o in s:
o = (o + 1) % 20
v = o + 1
print('{} {}'.format(v, 0))
x[o] = len(input().split()) - 1
if (x[o] >= 5):
s.add(o)
o = (o + 1) % 20
elif d < 100:
if e is None:
m = 101
for i, v in enumerate(x):
if v < m:
m = v
e = i
s.add(e)
m, k = 101, None
for i, v in enumerate(x):
if v < m and i != e:
m = v
k = i
print('{} {}'.format(k + 1, 100))
x[k] += 1
if x[k] >= 5:
s.add(k)
else:
print('{} 100'.format(20))
if d == 100:
break