結果
問題 |
No.649 ここでちょっとQK!
|
ユーザー |
|
提出日時 | 2022-03-02 16:16:21 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,216 ms / 3,000 ms |
コード長 | 597 bytes |
コンパイル時間 | 117 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 18,688 KB |
最終ジャッジ日時 | 2024-07-16 08:34:42 |
合計ジャッジ時間 | 16,796 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
import heapq q, k = map(int, input().split()) k_elements = [] #max tmp = [] #min for _ in range(q): que = list(map(int, input().split())) if que[0] == 1: v = que[1] heapq.heappush(k_elements, -v) if len(k_elements) > k: maxv = -heapq.heappop(k_elements) heapq.heappush(tmp, maxv) else: if len(k_elements) != k: print(-1) else: maxv = -heapq.heappop(k_elements) print(maxv) if tmp: minv = heapq.heappop(tmp) heapq.heappush(k_elements, -minv)