結果

問題 No.3298 K-th Slime
ユーザー sasa8uyauya
提出日時 2025-10-10 12:13:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 398 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 418 ms
コンパイル使用メモリ 82,612 KB
実行使用メモリ 93,544 KB
最終ジャッジ日時 2025-10-10 12:13:33
合計ジャッジ時間 7,463 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

n,K,Q=map(int,input().split())
a=list(map(int,input().split()))
from heapq import heappush,heappop
a.sort()
q1=[-v for v in a[:K][::-1]]
q2=a[K:]
for _ in range(Q):
  q=list(map(int,input().split()))
  t=q[0]
  if t==1:
    x=q[1]
    if -q1[0]<=x:
      heappush(q2,x)
    else:
      heappush(q2,-heappop(q1))
      heappush(q1,-x)
  if t==2:
    y=q[1]
    x=-heappop(q1)+y
    heappush(q2,x)
    heappush(q1,-heappop(q2))
  if t==3:
    print(-q1[0])
0