結果

問題 No.649 ここでちょっとQK!
ユーザー maspymaspy
提出日時 2020-03-03 14:35:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 349 ms / 3,000 ms
コード長 759 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 36,608 KB
最終ジャッジ日時 2024-04-22 00:00:21
合計ジャッジ時間 8,551 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
10,752 KB
testcase_01 AC 34 ms
10,752 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 AC 147 ms
33,280 KB
testcase_04 AC 344 ms
35,072 KB
testcase_05 AC 236 ms
34,688 KB
testcase_06 AC 261 ms
36,608 KB
testcase_07 AC 33 ms
10,752 KB
testcase_08 AC 32 ms
10,624 KB
testcase_09 AC 33 ms
10,624 KB
testcase_10 AC 33 ms
10,752 KB
testcase_11 AC 34 ms
10,624 KB
testcase_12 AC 133 ms
21,376 KB
testcase_13 AC 141 ms
21,376 KB
testcase_14 AC 132 ms
21,376 KB
testcase_15 AC 154 ms
21,632 KB
testcase_16 AC 172 ms
24,448 KB
testcase_17 AC 204 ms
24,576 KB
testcase_18 AC 223 ms
25,856 KB
testcase_19 AC 243 ms
26,752 KB
testcase_20 AC 252 ms
27,904 KB
testcase_21 AC 265 ms
28,800 KB
testcase_22 AC 281 ms
30,208 KB
testcase_23 AC 303 ms
30,848 KB
testcase_24 AC 322 ms
32,000 KB
testcase_25 AC 344 ms
33,280 KB
testcase_26 AC 349 ms
34,176 KB
testcase_27 AC 36 ms
10,752 KB
testcase_28 AC 34 ms
10,752 KB
testcase_29 AC 34 ms
10,752 KB
testcase_30 AC 126 ms
20,096 KB
testcase_31 AC 174 ms
22,016 KB
testcase_32 AC 34 ms
10,624 KB
testcase_33 AC 34 ms
10,752 KB
testcase_34 AC 33 ms
10,752 KB
testcase_35 AC 33 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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())))
0