結果

問題 No.2232 Miser's Gift
ユーザー chankei271828chankei271828
提出日時 2023-03-03 23:03:06
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 991 bytes
コンパイル時間 1,808 ms
コンパイル使用メモリ 81,656 KB
実行使用メモリ 242,220 KB
最終ジャッジ日時 2023-10-18 03:24:34
合計ジャッジ時間 11,025 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,500 KB
testcase_01 AC 43 ms
55,500 KB
testcase_02 AC 43 ms
55,500 KB
testcase_03 AC 158 ms
84,492 KB
testcase_04 AC 1,507 ms
214,964 KB
testcase_05 AC 67 ms
70,772 KB
testcase_06 AC 43 ms
55,500 KB
testcase_07 AC 77 ms
81,804 KB
testcase_08 AC 94 ms
82,460 KB
testcase_09 AC 94 ms
82,520 KB
testcase_10 AC 94 ms
82,460 KB
testcase_11 AC 95 ms
82,460 KB
testcase_12 AC 94 ms
82,460 KB
testcase_13 AC 183 ms
85,488 KB
testcase_14 AC 183 ms
85,888 KB
testcase_15 AC 176 ms
85,320 KB
testcase_16 AC 177 ms
85,216 KB
testcase_17 AC 185 ms
85,816 KB
testcase_18 AC 184 ms
85,872 KB
testcase_19 AC 184 ms
85,384 KB
testcase_20 AC 172 ms
85,360 KB
testcase_21 AC 180 ms
85,568 KB
testcase_22 AC 180 ms
85,732 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 1,740 ms
183,660 KB
testcase_29 AC 1,741 ms
177,680 KB
testcase_30 AC 1,655 ms
181,428 KB
testcase_31 AC 1,798 ms
177,940 KB
testcase_32 AC 1,844 ms
185,996 KB
testcase_33 AC 298 ms
98,744 KB
testcase_34 AC 313 ms
99,500 KB
testcase_35 AC 312 ms
97,428 KB
testcase_36 AC 276 ms
95,040 KB
testcase_37 AC 301 ms
97,428 KB
testcase_38 AC 131 ms
76,380 KB
testcase_39 AC 129 ms
76,452 KB
testcase_40 AC 126 ms
76,452 KB
testcase_41 AC 128 ms
76,396 KB
testcase_42 AC 127 ms
76,344 KB
testcase_43 AC 127 ms
76,364 KB
testcase_44 AC 134 ms
76,432 KB
testcase_45 AC 129 ms
76,436 KB
testcase_46 AC 133 ms
76,928 KB
testcase_47 AC 134 ms
77,116 KB
testcase_48 AC 73 ms
72,532 KB
testcase_49 AC 70 ms
70,476 KB
testcase_50 AC 68 ms
70,468 KB
testcase_51 AC 67 ms
70,452 KB
testcase_52 AC 70 ms
70,472 KB
testcase_53 AC 70 ms
70,468 KB
testcase_54 AC 73 ms
72,532 KB
testcase_55 AC 68 ms
70,448 KB
testcase_56 AC 69 ms
70,476 KB
testcase_57 AC 68 ms
70,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque,defaultdict
N,W=map(int,input().split())
pre=[tuple(map(int,input().split())) for _ in range(N)]
dp=dict()
#dp[i][j]:i番目の品物までで、重さjになる組み合わせの中での勝ちの総和の最大値
#配る
d=deque()
d.append(0)
dp[0]=0
while d:
    n=d.popleft()
    i,j=divmod(n,10**6)
    if i==N:
        break
    now=dp.pop(n)
    if (i+1)*10**6+j not in dp:
        dp[(i+1)*10**6+j]=0
        d.append((i+1)*10**6+j)
    dp[(i+1)*10**6+j]=max(now,dp[(i+1)*10**6+j])
    w,v=pre[i]
    if j+w<=W:
        if (i+1)*10**6+j+w not in dp:
            dp[(i+1)*10**6+j+w]=0
            d.append((i+1)*10**6+j+w)
        dp[(i+1)*10**6+j+w]=max(now+v,dp[(i+1)*10**6+j+w])
ans=[]
for j in range(W+1):
    if j==0:
        ans.append(0)
    else:
        if N*10**6+j not in dp:
            ans.append(ans[-1])
        else:
            ans.append(max(dp[N*10**6+j],ans[-1]))
ans_now=ans[W]
for X in range(1,W+1):
    print(ans_now-(ans[W-X])+1)
0