結果
問題 | No.618 labo-index |
ユーザー | Ryuto |
提出日時 | 2018-03-05 20:02:33 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,541 bytes |
コンパイル時間 | 168 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 66,176 KB |
最終ジャッジ日時 | 2024-09-13 14:12:15 |
合計ジャッジ時間 | 3,568 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | RE | - |
ソースコード
#!/usr/bin/env python import copy Q = int(input()) Q = 20 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