結果

問題 No.2693 Sword
ユーザー dp_ijkdp_ijk
提出日時 2024-03-22 21:43:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 581 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,892 KB
最終ジャッジ日時 2024-03-22 21:43:47
合計ジャッジ時間 3,030 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 39 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 47 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 64 ms
72,656 KB
testcase_10 AC 47 ms
61,968 KB
testcase_11 AC 56 ms
66,484 KB
testcase_12 AC 37 ms
53,460 KB
testcase_13 AC 52 ms
64,424 KB
testcase_14 AC 43 ms
59,708 KB
testcase_15 AC 73 ms
73,592 KB
testcase_16 AC 86 ms
75,768 KB
testcase_17 AC 75 ms
75,612 KB
testcase_18 AC 60 ms
68,548 KB
testcase_19 AC 62 ms
70,640 KB
testcase_20 AC 84 ms
75,736 KB
testcase_21 AC 92 ms
75,892 KB
testcase_22 AC 79 ms
75,768 KB
testcase_23 AC 66 ms
70,616 KB
testcase_24 AC 37 ms
53,460 KB
testcase_25 AC 37 ms
53,460 KB
testcase_26 AC 36 ms
53,460 KB
testcase_27 AC 37 ms
53,460 KB
testcase_28 AC 37 ms
53,460 KB
testcase_29 AC 37 ms
53,460 KB
testcase_30 AC 37 ms
53,460 KB
testcase_31 AC 37 ms
53,460 KB
testcase_32 AC 69 ms
73,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = float("INF")
N, P, K = map(int, input().split())

items = []
for _ in range(N):
   t, b = map(int, input().split())
   items.append((t, b))

dp = [-INF] * (N+1)
dp[0] = P

U = 10**18


def chmax(A, idx, val):
   if U < val:
      val = INF
   if A[idx] < val:
      A[idx] = val


for i, (t, b) in enumerate(items):
   ndp = dp[:]
   for j in range(i+1):
      if dp[j] < 0:
         continue
      if t == 1:
         chmax(ndp, j+1, dp[j] + b)
      elif t == 2:
         chmax(ndp, j+1, dp[j] * 2)
   dp = ndp


ans = dp[K]
if ans == INF:
   print(-1)
else:
   print(ans)
0