first commit

from old repository to a new repository
This commit is contained in:
Gyubin Han
2024-04-30 16:59:10 +09:00
commit 2600340c03
93 changed files with 1610 additions and 0 deletions

48
boj/7662.py Normal file
View File

@@ -0,0 +1,48 @@
from sys import stdin
import heapq
n=int(stdin.readline().rstrip())
for a in range(n):
m=int(stdin.readline().rstrip())
maxh,minh=[],[]
isdel=dict()
cnt=0
for i in range(m):
s=list(map(str,stdin.readline().rstrip().split()))
v=int(s[1])
if s[0]=='I':
heapq.heappush(maxh,(-v,i))
heapq.heappush(minh,(v,i))
isdel[i]=True
cnt+=1
else:
if cnt>0:
if v==-1:
while minh and not isdel[minh[0][1]]:
heapq.heappop(minh)
d=heapq.heappop(minh)
else:
while maxh and not isdel[maxh[0][1]]:
heapq.heappop(maxh)
d=heapq.heappop(maxh)
# print(d[0],d[1])
isdel[d[1]]=False
cnt-=1
else:
continue
# print(maxh)
# print(minh)
while minh and not isdel[minh[0][1]]:
heapq.heappop(minh)
while maxh and not isdel[maxh[0][1]]:
heapq.heappop(maxh)
# print(maxh)
# print(minh)
if cnt>0:
print(-maxh[0][0],minh[0][0])
else:
print("EMPTY")