結果

問題 No.649 ここでちょっとQK!
ユーザー ああいいああいい
提出日時 2022-01-09 22:42:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 843 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 167,556 KB
最終ジャッジ日時 2024-04-26 19:55:47
合計ジャッジ時間 10,167 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 123 ms
83,860 KB
testcase_04 AC 265 ms
167,428 KB
testcase_05 AC 260 ms
167,556 KB
testcase_06 AC 187 ms
85,308 KB
testcase_07 AC 39 ms
51,712 KB
testcase_08 AC 40 ms
52,096 KB
testcase_09 AC 39 ms
52,480 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 240 ms
117,000 KB
testcase_13 AC 241 ms
116,844 KB
testcase_14 AC 233 ms
117,484 KB
testcase_15 AC 254 ms
116,992 KB
testcase_16 AC 249 ms
117,388 KB
testcase_17 AC 265 ms
123,632 KB
testcase_18 AC 290 ms
128,304 KB
testcase_19 AC 304 ms
134,796 KB
testcase_20 AC 316 ms
136,628 KB
testcase_21 AC 334 ms
145,452 KB
testcase_22 AC 349 ms
144,560 KB
testcase_23 AC 366 ms
151,720 KB
testcase_24 AC 393 ms
139,988 KB
testcase_25 AC 407 ms
166,992 KB
testcase_26 AC 427 ms
145,084 KB
testcase_27 AC 56 ms
63,360 KB
testcase_28 AC 54 ms
62,848 KB
testcase_29 AC 54 ms
62,208 KB
testcase_30 AC 193 ms
103,884 KB
testcase_31 AC 209 ms
104,908 KB
testcase_32 AC 39 ms
51,840 KB
testcase_33 AC 39 ms
52,224 KB
testcase_34 AC 42 ms
52,096 KB
testcase_35 AC 41 ms
51,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
r = sys.stdin
Q,K = map(int,r.readline().split())

l = []
s = set()
for _ in range(Q):
    a = list(map(int,r.readline().split()))
    if a[0] == 1:
        l.append(a[1])
        s.add(a[1])
    else:
        l.append(-2)
D = {v:i+1 for i,v in enumerate(sorted(s))}
rD = {i+1:v for i,v in enumerate(sorted(s))}

n = len(D)
bit = [0] * (n +1)
def add(i,x):
    while i <= n:
        bit[i] += x
        i += i &-i
def lb(w):
    if w <= 0:return 0
    k = 1
    while k < n:
        k <<= 1
    k >>= 1
    x = 0
    while k > 0:
        if x + k <= n and bit[x+k] < w:
            w -= bit[x+k]
            x += k
        k >>= 1
    return x + 1

for v in l:
    if v != -2:
        add(D[v],1)
    else:
        x = lb(K)
        if x == n + 1:
            print(-1)
        else:
            print(rD[x])
            add(x,-1)

0