結果

問題 No.2693 Sword
コンテスト
ユーザー miya145592
提出日時 2024-03-22 22:18:29
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 615 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,069 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 72,960 KB
最終ジャッジ日時 2026-04-16 15:28:09
合計ジャッジ時間 3,590 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline
N, P, K = map(int, input().split())
TB = [list(map(int, input().split())) for _ in range(N)]
dp = [0 for _ in range(K+1)]
dp[0] = P
for i in range(N):
    ndp = [0 for _ in range(K+1)]
    for j in range(K+1):
        if dp[j]==0:
            continue
        ndp[j] = max(ndp[j], dp[j])
        if j+1<=K:
            t, b = TB[i]
            if t==1:
                ndp[j+1] = max(ndp[j+1], dp[j]+b)
            else:
                ndp[j+1] = max(ndp[j+1], dp[j]*2)
            if ndp[j+1]>10**18:
                print(-1)
                exit()
    dp = ndp
print(dp[K])
0