結果

問題 No.2232 Miser's Gift
ユーザー flygonflygon
提出日時 2023-03-03 21:31:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 294 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 1,384 ms
コンパイル使用メモリ 81,468 KB
実行使用メモリ 155,364 KB
最終ジャッジ日時 2023-10-18 01:27:05
合計ジャッジ時間 12,470 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,284 KB
testcase_01 AC 38 ms
53,284 KB
testcase_02 AC 38 ms
53,284 KB
testcase_03 AC 202 ms
155,308 KB
testcase_04 AC 241 ms
155,364 KB
testcase_05 AC 72 ms
75,892 KB
testcase_06 AC 38 ms
53,284 KB
testcase_07 AC 66 ms
77,832 KB
testcase_08 AC 207 ms
155,364 KB
testcase_09 AC 210 ms
155,364 KB
testcase_10 AC 207 ms
155,364 KB
testcase_11 AC 233 ms
155,364 KB
testcase_12 AC 209 ms
155,364 KB
testcase_13 AC 206 ms
155,308 KB
testcase_14 AC 204 ms
155,308 KB
testcase_15 AC 204 ms
155,308 KB
testcase_16 AC 203 ms
155,308 KB
testcase_17 AC 204 ms
155,308 KB
testcase_18 AC 206 ms
155,308 KB
testcase_19 AC 204 ms
155,308 KB
testcase_20 AC 204 ms
155,308 KB
testcase_21 AC 203 ms
155,308 KB
testcase_22 AC 201 ms
155,308 KB
testcase_23 AC 287 ms
155,364 KB
testcase_24 AC 293 ms
155,364 KB
testcase_25 AC 284 ms
155,364 KB
testcase_26 AC 294 ms
155,364 KB
testcase_27 AC 280 ms
155,364 KB
testcase_28 AC 223 ms
155,364 KB
testcase_29 AC 223 ms
155,364 KB
testcase_30 AC 222 ms
155,364 KB
testcase_31 AC 236 ms
155,364 KB
testcase_32 AC 240 ms
155,364 KB
testcase_33 AC 203 ms
155,308 KB
testcase_34 AC 205 ms
155,308 KB
testcase_35 AC 205 ms
155,308 KB
testcase_36 AC 204 ms
155,308 KB
testcase_37 AC 204 ms
155,308 KB
testcase_38 AC 55 ms
63,800 KB
testcase_39 AC 55 ms
63,800 KB
testcase_40 AC 55 ms
63,800 KB
testcase_41 AC 55 ms
63,800 KB
testcase_42 AC 55 ms
63,800 KB
testcase_43 AC 55 ms
63,800 KB
testcase_44 AC 55 ms
63,800 KB
testcase_45 AC 56 ms
63,800 KB
testcase_46 AC 55 ms
63,672 KB
testcase_47 AC 55 ms
63,800 KB
testcase_48 AC 49 ms
61,436 KB
testcase_49 AC 49 ms
61,436 KB
testcase_50 AC 49 ms
61,436 KB
testcase_51 AC 49 ms
61,436 KB
testcase_52 AC 49 ms
61,436 KB
testcase_53 AC 49 ms
61,436 KB
testcase_54 AC 48 ms
61,420 KB
testcase_55 AC 48 ms
61,436 KB
testcase_56 AC 49 ms
61,436 KB
testcase_57 AC 49 ms
61,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,w = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(n)]
INF = 10**15
dp = [-INF]*(w+1) 
dp[0] = 0
for i in range(1,n+1):
  new = [-INF]*(w+1) 
  wi,vi = wv[i-1]
  for j in range(w+1):
    new[j] = dp[j]
    if j >= wi:
      new[j] = max(new[j], dp[j-wi] + vi)
  dp = new

pre = dp[::1]
for i in range(1,w+1):
  pre[i] = max(pre[i-1], pre[i])
mx = max(dp)
for x in range(1,w+1):
  ans = mx - pre[w-x] + 1
  print(ans)
  
0