結果
| 問題 | No.2232 Miser's Gift |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-03 21:54:37 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 98 ms / 2,000 ms |
| コード長 | 297 bytes |
| 記録 | |
| コンパイル時間 | 1,290 ms |
| コンパイル使用メモリ | 84,864 KB |
| 実行使用メモリ | 82,048 KB |
| 最終ジャッジ日時 | 2026-04-06 11:59:36 |
| 合計ジャッジ時間 | 6,578 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 55 |
ソースコード
n,W = map(int,input().split())
WV = [list(map(int,input().split())) for i in range(n)]
dp = [0]*(W+1)
for w,v in WV:
for i in range(W)[::-1]:
if i+w <= W and dp[i+w] < dp[i]+v:
dp[i+w] = dp[i]+v
base = dp[-1]
for i in range(W)[::-1]:
num = dp[i]
print(base-num+1)