結果

問題 No.649 ここでちょっとQK!
ユーザー rlangevinrlangevin
提出日時 2023-05-25 12:16:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 366 ms / 3,000 ms
コード長 748 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 86,880 KB
実行使用メモリ 89,096 KB
最終ジャッジ日時 2023-08-25 19:55:24
合計ジャッジ時間 11,618 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
70,904 KB
testcase_01 AC 71 ms
71,176 KB
testcase_02 AC 74 ms
70,860 KB
testcase_03 AC 183 ms
77,568 KB
testcase_04 AC 278 ms
88,548 KB
testcase_05 AC 288 ms
89,096 KB
testcase_06 AC 217 ms
84,648 KB
testcase_07 AC 72 ms
71,040 KB
testcase_08 AC 73 ms
70,984 KB
testcase_09 AC 74 ms
70,692 KB
testcase_10 AC 72 ms
70,944 KB
testcase_11 AC 74 ms
71,216 KB
testcase_12 AC 221 ms
83,180 KB
testcase_13 AC 211 ms
82,632 KB
testcase_14 AC 202 ms
83,112 KB
testcase_15 AC 281 ms
84,080 KB
testcase_16 AC 233 ms
81,288 KB
testcase_17 AC 276 ms
82,060 KB
testcase_18 AC 288 ms
82,632 KB
testcase_19 AC 293 ms
84,872 KB
testcase_20 AC 306 ms
83,840 KB
testcase_21 AC 315 ms
85,728 KB
testcase_22 AC 322 ms
85,292 KB
testcase_23 AC 331 ms
86,424 KB
testcase_24 AC 341 ms
86,920 KB
testcase_25 AC 351 ms
87,184 KB
testcase_26 AC 366 ms
88,592 KB
testcase_27 AC 90 ms
75,924 KB
testcase_28 AC 90 ms
76,132 KB
testcase_29 AC 94 ms
76,056 KB
testcase_30 AC 255 ms
84,420 KB
testcase_31 AC 260 ms
81,604 KB
testcase_32 AC 74 ms
71,056 KB
testcase_33 AC 74 ms
70,944 KB
testcase_34 AC 74 ms
71,052 KB
testcase_35 AC 72 ms
71,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import *

Q, K = map(int, input().split())
H1, H2 = [], []
cnt = 0
for _ in range(Q):
    query = list(map(int, input().split()))
    if query[0] == 1:
        v = query[1]
        if cnt < K:
            heappush(H1, -v)
            cnt += 1
        else:
            maxv = -heappop(H1)
            if v <= maxv:
                heappush(H1, -v)
                heappush(H2, maxv)
            else:
                heappush(H1, -maxv)
                heappush(H2, v)
    else:
        if cnt < K:
            print(-1)
        else:
            print(-heappop(H1))
            if H2:
                minv = heappop(H2)
                heappush(H1, -minv)
            else:
                cnt -= 1
0