結果

問題 No.2693 Sword
ユーザー detteiuudetteiuu
提出日時 2024-05-18 00:10:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 82,284 KB
実行使用メモリ 84,660 KB
最終ジャッジ日時 2024-05-18 00:10:15
合計ジャッジ時間 3,579 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
53,360 KB
testcase_01 AC 47 ms
52,260 KB
testcase_02 AC 40 ms
53,420 KB
testcase_03 AC 43 ms
52,816 KB
testcase_04 AC 43 ms
53,856 KB
testcase_05 AC 43 ms
52,744 KB
testcase_06 AC 40 ms
52,444 KB
testcase_07 AC 38 ms
52,936 KB
testcase_08 AC 39 ms
53,484 KB
testcase_09 AC 74 ms
72,224 KB
testcase_10 AC 53 ms
64,352 KB
testcase_11 AC 62 ms
68,084 KB
testcase_12 AC 39 ms
53,260 KB
testcase_13 AC 57 ms
66,356 KB
testcase_14 AC 47 ms
60,668 KB
testcase_15 AC 88 ms
78,092 KB
testcase_16 AC 89 ms
78,128 KB
testcase_17 AC 83 ms
74,188 KB
testcase_18 AC 72 ms
71,048 KB
testcase_19 AC 86 ms
74,124 KB
testcase_20 AC 77 ms
69,628 KB
testcase_21 AC 75 ms
72,640 KB
testcase_22 AC 109 ms
78,336 KB
testcase_23 AC 74 ms
68,520 KB
testcase_24 AC 48 ms
54,760 KB
testcase_25 AC 46 ms
52,476 KB
testcase_26 AC 46 ms
52,532 KB
testcase_27 AC 47 ms
53,168 KB
testcase_28 AC 45 ms
53,272 KB
testcase_29 AC 47 ms
53,116 KB
testcase_30 AC 46 ms
54,052 KB
testcase_31 AC 45 ms
53,264 KB
testcase_32 AC 110 ms
84,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, P, K = map(int, input().split())
TB = [list(map(int, input().split())) for _ in range(N)]

dp = [[-1]*(K+1) for _ in range(N+1)]
dp[0][0] = P
limit = 10**18+1
for i in range(N):
    T, B = TB[i]
    for j in range(K+1):
        if dp[i][j] != -1:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
            if j < K:
                if T == 1:
                    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+B)
                    dp[i+1][j+1] = min(dp[i+1][j+1], limit)
                else:
                    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]*2)
                    dp[i+1][j+1] = min(dp[i+1][j+1], limit)

print(dp[-1][-1] if dp[-1][-1] != limit else -1)
0