結果

問題 No.2693 Sword
ユーザー noriocnorioc
提出日時 2024-03-22 22:47:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 90,328 KB
最終ジャッジ日時 2024-03-22 22:47:42
合計ジャッジ時間 3,530 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,332 KB
testcase_01 AC 37 ms
53,332 KB
testcase_02 AC 36 ms
53,332 KB
testcase_03 AC 37 ms
53,332 KB
testcase_04 AC 36 ms
53,332 KB
testcase_05 AC 37 ms
53,332 KB
testcase_06 AC 37 ms
53,332 KB
testcase_07 AC 36 ms
53,332 KB
testcase_08 AC 37 ms
53,332 KB
testcase_09 AC 63 ms
68,136 KB
testcase_10 AC 48 ms
61,720 KB
testcase_11 AC 56 ms
66,100 KB
testcase_12 AC 36 ms
53,332 KB
testcase_13 AC 52 ms
64,040 KB
testcase_14 AC 47 ms
61,724 KB
testcase_15 AC 94 ms
77,456 KB
testcase_16 AC 84 ms
77,068 KB
testcase_17 AC 127 ms
78,576 KB
testcase_18 AC 81 ms
76,460 KB
testcase_19 AC 70 ms
72,508 KB
testcase_20 AC 59 ms
66,216 KB
testcase_21 AC 62 ms
68,280 KB
testcase_22 AC 73 ms
72,484 KB
testcase_23 AC 58 ms
66,232 KB
testcase_24 AC 38 ms
53,332 KB
testcase_25 AC 36 ms
53,332 KB
testcase_26 AC 38 ms
53,332 KB
testcase_27 AC 37 ms
53,332 KB
testcase_28 AC 38 ms
53,332 KB
testcase_29 AC 38 ms
53,332 KB
testcase_30 AC 37 ms
53,332 KB
testcase_31 AC 37 ms
53,332 KB
testcase_32 AC 159 ms
90,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, P, K = map(int, input().split())
items = []
for _ in range(N):
    T, B = map(int, input().split())
    items.append((T, B))

dp = [[0] * (K+1) for _ in range(N+1)]
dp[0][0] = P

for i in range(N):
    for j in range(K+1):
        dp[i+1][j] = dp[i][j]

    t, b = items[i]
    for j in range(K):
        if t == 1:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + b)
        else:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] * 2)

res = dp[N][K]
if res > 10**18:
    print(-1)
else:
    print(res)
0