結果

問題 No.2093 Shio Ramen
ユーザー KamikazeeKamikazee
提出日時 2022-10-05 20:04:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 85,268 KB
最終ジャッジ日時 2023-08-30 21:08:07
合計ジャッジ時間 5,617 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,092 KB
testcase_01 AC 70 ms
71,164 KB
testcase_02 AC 69 ms
71,408 KB
testcase_03 AC 70 ms
71,200 KB
testcase_04 AC 70 ms
71,092 KB
testcase_05 AC 69 ms
70,908 KB
testcase_06 AC 71 ms
71,272 KB
testcase_07 AC 71 ms
71,352 KB
testcase_08 AC 69 ms
71,196 KB
testcase_09 AC 88 ms
76,260 KB
testcase_10 AC 115 ms
82,040 KB
testcase_11 AC 81 ms
76,004 KB
testcase_12 AC 91 ms
75,952 KB
testcase_13 AC 94 ms
76,116 KB
testcase_14 AC 94 ms
76,428 KB
testcase_15 AC 100 ms
76,076 KB
testcase_16 AC 87 ms
76,332 KB
testcase_17 AC 97 ms
76,660 KB
testcase_18 AC 122 ms
84,304 KB
testcase_19 AC 114 ms
81,840 KB
testcase_20 AC 101 ms
76,392 KB
testcase_21 AC 109 ms
80,264 KB
testcase_22 AC 108 ms
80,152 KB
testcase_23 AC 125 ms
85,184 KB
testcase_24 AC 124 ms
85,268 KB
testcase_25 AC 119 ms
84,776 KB
testcase_26 AC 124 ms
84,788 KB
testcase_27 AC 124 ms
85,032 KB
testcase_28 AC 121 ms
84,944 KB
testcase_29 AC 124 ms
84,976 KB
testcase_30 AC 122 ms
84,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,w = map(int, input().split())
weight,value = [],[]
dp = [[0 for i in range(w + 1)] for i in range(n + 1)]
for i in range(n):
  a,b = map(int, input().split())
  weight.append(a)
  value.append(b)
for i in range(n + 1):
  for j in range(w + 1):
    if i == 0 or j == 0:
      dp[i][j] = 0
    elif weight[i - 1] <= j:
      dp[i][j] = max(value[i - 1] + dp[i - 1][j - weight[i - 1]], dp[i - 1][j])
    else:
      dp[i][j] = dp[i - 1][j]
print(dp[n][w])
0