結果

問題 No.2693 Sword
コンテスト
ユーザー miya145592
提出日時 2024-03-22 22:18:29
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 80 ms / 2,000 ms
+ 313µs
コード長 615 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,946 ms
コンパイル使用メモリ 95,896 KB
実行使用メモリ 83,584 KB
最終ジャッジ日時 2026-09-06 17:16:29
合計ジャッジ時間 6,330 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_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