結果
| 問題 | No.649 ここでちょっとQK! |
| コンテスト | |
| ユーザー |
anagohirame
|
| 提出日時 | 2020-09-04 12:05:56 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 299 ms / 3,000 ms |
| + 155µs | |
| コード長 | 484 bytes |
| 記録 | |
| コンパイル時間 | 55 ms |
| コンパイル使用メモリ | 15,104 KB |
| 実行使用メモリ | 19,200 KB |
| 最終ジャッジ日時 | 2026-09-29 17:41:04 |
| 合計ジャッジ時間 | 8,989 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
from heapq import heappush, heappop import sys def input(): return sys.stdin.buffer.readline()[:-1] n, k = map(int, input().split()) q1, q2 = [], [] def add(x): heappush(q1, -x) if len(q1) > k: tmp = heappop(q1) heappush(q2, -tmp) return def remove(): if len(q1) < k: return -1 else: res = heappop(q1) if q2: nxt = heappop(q2) heappush(q1, -nxt) return -res for _ in range(n): t = input().split() if len(t) == 2: add(int(t[1])) else: print(remove())
anagohirame