結果

問題 No.618 labo-index
ユーザー RyutoRyuto
提出日時 2018-03-05 19:50:12
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,534 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 79,552 KB
最終ジャッジ日時 2023-10-11 15:08:46
合計ジャッジ時間 12,387 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,572 KB
testcase_01 AC 88 ms
71,352 KB
testcase_02 AC 88 ms
71,508 KB
testcase_03 AC 90 ms
71,496 KB
testcase_04 AC 199 ms
78,296 KB
testcase_05 AC 215 ms
79,216 KB
testcase_06 AC 98 ms
75,844 KB
testcase_07 AC 127 ms
77,620 KB
testcase_08 AC 149 ms
79,172 KB
testcase_09 AC 159 ms
78,376 KB
testcase_10 AC 190 ms
78,732 KB
testcase_11 AC 163 ms
78,784 KB
testcase_12 AC 147 ms
78,072 KB
testcase_13 AC 187 ms
79,008 KB
testcase_14 AC 160 ms
78,784 KB
testcase_15 AC 188 ms
78,928 KB
testcase_16 AC 196 ms
78,888 KB
testcase_17 AC 155 ms
79,552 KB
testcase_18 AC 239 ms
79,324 KB
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python

import copy

Q = int(input())
events = []
for i in range(Q):
    events.append([int(x) for x in input().split()])

N = 0
addlist = [0]
keylist = []
dp = {}
for event in events:
    if event[0] == 1:
        x = event[1]
        N += 1
        addlist.append(x)
        keylist = sorted(list(set(keylist + [x])))
        for k in keylist:
            if k < x:
                dp[k] += 1
        if x in dp.keys():
            dp[x] += 1
        elif x == keylist[-1]:
            dp[x] = 1
        else:
            dp[x] = dp[keylist[keylist.index(x)+1]] + 1
    elif event[0] == 2:
        N -= 1
        if N == 0:
            dp = {}
            keylist = []
        else:
            x = addlist[event[1]]
            for k in keylist:
                if k <= x:
                    dp[k] = max(0, dp[k] - 1)
    elif event[0] == 3:
        x = event[1]
        addlist = [v+x for v in addlist]
        keylist = [i+x for i in keylist]
        dp_new = {k:dp[k-x] for k in keylist}
        dp = copy.deepcopy(dp_new)

    ansdp = [(k, v) for k, v in dp.items() if k >= 0]
    if len(ansdp) == 0:
        print(0)
    else:
        ansdp.sort(reverse=True)
        for i, val in enumerate(ansdp):
            if val[1] >= val[0]:
                print(val[0])
                break
            elif i+1 == len(ansdp):
                print(val[1])
                break
            elif val[1] >= ansdp[i+1][0]:
                print(val[1])
                break
            else:
                continue
0