-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha513.py
More file actions
28 lines (23 loc) · 748 Bytes
/
a513.py
File metadata and controls
28 lines (23 loc) · 748 Bytes
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
import heapq
T = int(input())
r = []
for i in range(T):
N,M = map(int, input().split())
nums = list(map(int, input().split()))
nums_heap = [-n for n in nums]
heapq.heapify(nums_heap)
print(f"Case {i+1}:")
for _ in range(M):
status = list(map(int, input().split()))
if status[0] == 1:
heapq.heappush(nums_heap,-status[1])
else:
if nums_heap:
value = -heapq.heappop(nums_heap)
print("Max:", value)
else:
print("It's empty!")
if nums_heap:
print(" ".join(map(str, sorted([-n for n in nums_heap], reverse = True))))
else:
print("It's empty!")