結果

問題 No.2693 Sword
ユーザー Nikkuniku029Nikkuniku029
提出日時 2024-03-22 21:58:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 643 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 72,876 KB
最終ジャッジ日時 2024-03-22 21:58:05
合計ジャッジ時間 3,056 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 39 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 39 ms
53,460 KB
testcase_04 AC 39 ms
53,460 KB
testcase_05 AC 40 ms
53,460 KB
testcase_06 AC 39 ms
53,460 KB
testcase_07 AC 40 ms
53,460 KB
testcase_08 AC 39 ms
53,460 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 70 ms
70,900 KB
testcase_16 WA -
testcase_17 AC 69 ms
70,896 KB
testcase_18 AC 62 ms
68,852 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 39 ms
53,460 KB
testcase_25 AC 38 ms
53,460 KB
testcase_26 AC 38 ms
53,460 KB
testcase_27 AC 39 ms
53,460 KB
testcase_28 AC 38 ms
53,460 KB
testcase_29 AC 39 ms
53,460 KB
testcase_30 AC 39 ms
53,460 KB
testcase_31 AC 40 ms
53,460 KB
testcase_32 AC 64 ms
72,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, P, K = map(int, input().split())
# dp[i+1][j]:i番目まで見てj個のアイテムを装備したときの最大値
Lim = 10**18 + 1
dp = [[0] * (K + 1) for _ in range(N + 1)]
dp[0][0] = P
for i in range(N):
    T, B = map(int, input().split())
    for j in range(min(i + 2, K + 1)):
        if j == 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
            continue
        if T == 1:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - 1] + B)
        else:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - 1] * 2)
        dp[i + 1][j] = min(dp[i + 1][j], Lim)
ans = dp[N][K]
if ans == Lim:
    ans = -1
print(ans)
0