結果

問題 No.2693 Sword
ユーザー FromBooskaFromBooska
提出日時 2024-03-22 23:16:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 862 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 71,256 KB
最終ジャッジ日時 2024-03-22 23:16:34
合計ジャッジ時間 3,018 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,332 KB
testcase_01 AC 37 ms
53,332 KB
testcase_02 AC 38 ms
53,332 KB
testcase_03 AC 38 ms
53,332 KB
testcase_04 AC 37 ms
53,332 KB
testcase_05 AC 37 ms
53,332 KB
testcase_06 AC 40 ms
53,332 KB
testcase_07 AC 38 ms
53,332 KB
testcase_08 AC 37 ms
53,332 KB
testcase_09 AC 70 ms
70,212 KB
testcase_10 AC 50 ms
63,804 KB
testcase_11 AC 61 ms
66,104 KB
testcase_12 AC 38 ms
53,332 KB
testcase_13 AC 55 ms
64,044 KB
testcase_14 AC 40 ms
53,332 KB
testcase_15 AC 59 ms
65,832 KB
testcase_16 AC 67 ms
70,360 KB
testcase_17 AC 59 ms
68,120 KB
testcase_18 AC 52 ms
63,748 KB
testcase_19 AC 68 ms
70,392 KB
testcase_20 AC 66 ms
68,300 KB
testcase_21 AC 72 ms
70,380 KB
testcase_22 AC 71 ms
70,376 KB
testcase_23 AC 68 ms
68,320 KB
testcase_24 AC 38 ms
53,332 KB
testcase_25 AC 38 ms
53,332 KB
testcase_26 AC 38 ms
53,332 KB
testcase_27 AC 38 ms
53,332 KB
testcase_28 AC 39 ms
53,332 KB
testcase_29 AC 38 ms
53,332 KB
testcase_30 AC 39 ms
53,332 KB
testcase_31 AC 38 ms
53,332 KB
testcase_32 AC 57 ms
71,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 2次元dp、dp[i番目まで見て][j個使ったときの]最高値

N, P, K = map(int, input().split())
TB = []
for i in range(N):
    t, b = map(int, input().split())
    TB.append((t, b))

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

for i in range(1, N+1):
    t, b = TB[i-1]
    # 使わない
    for j in range(K+1):
        dp[i][j] = max(dp[i][j], dp[i-1][j])
    # 使う
    for j in range(K+1):
        if t == 1:
            if j+1<=K:
                dp[i][j+1] = max(dp[i][j+1], dp[i-1][j]+b)
                if dp[i][j+1] > 10**18:
                    print(-1)
                    exit()
        elif t == 2:
            if j+1<=K:
                dp[i][j+1] = max(dp[i][j+1], dp[i-1][j]*2)
                if dp[i][j+1] > 10**18:
                    print(-1)
                    exit()
    #print(dp[i])
    
ans = dp[N][K]
print(ans)
0