from collections import deque res = [] n = int(input()) tab = deque() for i in range(n): a = input().split() if a[0] == 'TAK': tab.append((i + 1, int(a[1]))) for i in range(10): if tab: a = tab.popleft() res.append(a[0]) if tab: k = 0 while tab and k < 10: a = tab.popleft() if a[1] < 2: res.append(a[0]) k += 1 print(*res)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | from collections import deque res = [] n = int(input()) tab = deque() for i in range(n): a = input().split() if a[0] == 'TAK': tab.append((i + 1, int(a[1]))) for i in range(10): if tab: a = tab.popleft() res.append(a[0]) if tab: k = 0 while tab and k < 10: a = tab.popleft() if a[1] < 2: res.append(a[0]) k += 1 print(*res) |