結果
問題 |
No.649 ここでちょっとQK!
|
ユーザー |
![]() |
提出日時 | 2018-08-01 17:45:28 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 801 ms / 3,000 ms |
コード長 | 678 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 23,936 KB |
最終ジャッジ日時 | 2024-09-19 16:51:01 |
合計ジャッジ時間 | 13,906 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
import heapq q,k = map(int,input().split()) low,high,ans = [],[],[] size = 0 for i in range(q): s = list(map(int,input().split())) if s[0]==1: if size<k: heapq.heappush(low,-s[1]) size+=1 elif -low[0]>s[1]: heapq.heappush(high,-heapq.heappop(low)) heapq.heappush(low,-s[1]) else: heapq.heappush(high,s[1]) else: if size==k: ans.append(-low[0]) if high: low[0] = -heapq.heappop(high) else: heapq.heappop(low) size-=1 else: ans.append(-1) print("\n".join(map(str,ans)))