結果
| 問題 |
No.649 ここでちょっとQK!
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-03 14:35:04 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 320 ms / 3,000 ms |
| コード長 | 759 bytes |
| コンパイル時間 | 142 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 36,608 KB |
| 最終ジャッジ日時 | 2024-10-13 22:31:36 |
| 合計ジャッジ時間 | 7,692 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# %%
from heapq import heappushpop, heappush, heappop
INF = 10 ** 18 + 10
# %%
Q, K = map(int, readline().split())
query = readlines()
# %%
def solve():
small = [-INF] * (K - 1)
large = []
for q in query:
if q[0] == ord('1'):
x = int(q[2:])
y = -heappushpop(small, -x)
heappush(large, y)
else:
if large:
x = heappop(large)
if x == INF:
yield -1
else:
yield x
else:
yield -1
# %%
print('\n'.join(map(str, solve())))
maspy