結果

問題 No.649 ここでちょっとQK!
ユーザー 👑 KazunKazun
提出日時 2020-08-08 04:05:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 352 ms / 3,000 ms
コード長 677 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 81,624 KB
実行使用メモリ 90,208 KB
最終ジャッジ日時 2023-10-25 22:50:57
合計ジャッジ時間 10,699 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,392 KB
testcase_01 AC 37 ms
53,392 KB
testcase_02 AC 36 ms
53,392 KB
testcase_03 AC 154 ms
80,492 KB
testcase_04 AC 332 ms
90,208 KB
testcase_05 AC 229 ms
87,100 KB
testcase_06 AC 216 ms
84,568 KB
testcase_07 AC 36 ms
53,468 KB
testcase_08 AC 36 ms
53,468 KB
testcase_09 AC 37 ms
53,468 KB
testcase_10 AC 36 ms
53,468 KB
testcase_11 AC 36 ms
53,468 KB
testcase_12 AC 187 ms
81,052 KB
testcase_13 AC 187 ms
81,112 KB
testcase_14 AC 181 ms
80,876 KB
testcase_15 AC 257 ms
82,332 KB
testcase_16 AC 239 ms
81,216 KB
testcase_17 AC 267 ms
81,200 KB
testcase_18 AC 276 ms
81,544 KB
testcase_19 AC 289 ms
82,952 KB
testcase_20 AC 294 ms
83,700 KB
testcase_21 AC 304 ms
84,276 KB
testcase_22 AC 313 ms
84,876 KB
testcase_23 AC 319 ms
85,692 KB
testcase_24 AC 332 ms
86,472 KB
testcase_25 AC 344 ms
87,048 KB
testcase_26 AC 352 ms
87,764 KB
testcase_27 AC 59 ms
65,940 KB
testcase_28 AC 61 ms
65,944 KB
testcase_29 AC 65 ms
68,152 KB
testcase_30 AC 213 ms
82,044 KB
testcase_31 AC 254 ms
81,656 KB
testcase_32 AC 37 ms
53,468 KB
testcase_33 AC 35 ms
53,468 KB
testcase_34 AC 35 ms
53,468 KB
testcase_35 AC 37 ms
53,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

Q,K=map(int,input().split())
X=0
F=0

A,B=[],[]

Z=[0]*Q
for _ in range(Q):
    T=list(map(int,input().split()))

    if T[0]==1:
        v=T[1]
        X+=1

        if X>K:
            if v<-A[0]:
                u=-heapq.heappop(A)
                heapq.heappush(A,-v)
                heapq.heappush(B,u)
            else:
                heapq.heappush(B,v)
        else:
            heapq.heappush(A,-v)

    else:
        if X>=K:
            Z[F]=-heapq.heappop(A)

            if X>K:
                u=heapq.heappop(B)
                heapq.heappush(A,-u)
            X-=1
        else:
            Z[F]=-1
        F+=1

print("\n".join(map(str,Z[:F])))
0