結果

問題 No.649 ここでちょっとQK!
ユーザー syunsukesyunsuke
提出日時 2019-09-12 00:11:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 311 ms / 3,000 ms
コード長 620 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 88,808 KB
最終ジャッジ日時 2023-09-15 14:03:07
合計ジャッジ時間 8,867 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,324 KB
testcase_01 AC 75 ms
71,012 KB
testcase_02 AC 73 ms
71,264 KB
testcase_03 AC 150 ms
78,028 KB
testcase_04 AC 282 ms
88,808 KB
testcase_05 AC 191 ms
84,324 KB
testcase_06 AC 224 ms
85,020 KB
testcase_07 AC 74 ms
71,416 KB
testcase_08 AC 76 ms
71,160 KB
testcase_09 AC 75 ms
71,580 KB
testcase_10 AC 74 ms
71,440 KB
testcase_11 AC 74 ms
71,396 KB
testcase_12 AC 186 ms
81,592 KB
testcase_13 AC 174 ms
81,804 KB
testcase_14 AC 181 ms
81,536 KB
testcase_15 AC 236 ms
82,084 KB
testcase_16 AC 219 ms
81,752 KB
testcase_17 AC 251 ms
82,108 KB
testcase_18 AC 250 ms
81,736 KB
testcase_19 AC 258 ms
83,324 KB
testcase_20 AC 271 ms
84,748 KB
testcase_21 AC 274 ms
85,092 KB
testcase_22 AC 282 ms
84,896 KB
testcase_23 AC 293 ms
85,716 KB
testcase_24 AC 299 ms
86,304 KB
testcase_25 AC 295 ms
86,352 KB
testcase_26 AC 311 ms
87,496 KB
testcase_27 AC 84 ms
76,184 KB
testcase_28 AC 85 ms
76,324 KB
testcase_29 AC 90 ms
76,280 KB
testcase_30 AC 194 ms
82,032 KB
testcase_31 AC 227 ms
81,380 KB
testcase_32 AC 75 ms
71,520 KB
testcase_33 AC 76 ms
71,488 KB
testcase_34 AC 73 ms
71,248 KB
testcase_35 AC 72 ms
71,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Q,K=map(int,input().split())
A=[]
B=[]
import heapq
import sys
input=sys.stdin.readline
heapq.heapify(A)
heapq.heapify(B)
for i in range(Q):
    C=list(map(int,input().split()))
    #print(C)
    if len(C)==1:
        if len(B)==0:
            print(-1)
        else:
            a=heapq.heappop(B)
            print(a)
    else:
        if len(A)<K-1:
            heapq.heappush(A,-C[1])
        elif K==1:
            heapq.heappush(B,C[1])
        elif A[0]>(-1*C[1]):
            heapq.heappush(B,C[1])
        else:
            heapq.heappush(A,-C[1])
            c=heapq.heappop(A)
            heapq.heappush(B,-c)
0