結果

問題 No.2866 yuusaan's Knapsack
ユーザー titiatitia
提出日時 2024-09-05 02:05:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 761 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 98,200 KB
最終ジャッジ日時 2024-09-05 02:05:22
合計ジャッジ時間 5,276 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
74,128 KB
testcase_01 WA -
testcase_02 AC 63 ms
75,288 KB
testcase_03 AC 49 ms
65,576 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 188 ms
94,728 KB
testcase_07 WA -
testcase_08 AC 150 ms
90,876 KB
testcase_09 AC 144 ms
91,668 KB
testcase_10 AC 149 ms
92,940 KB
testcase_11 AC 121 ms
87,988 KB
testcase_12 AC 141 ms
90,992 KB
testcase_13 AC 152 ms
88,400 KB
testcase_14 AC 153 ms
89,880 KB
testcase_15 AC 156 ms
94,468 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 179 ms
96,336 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod=998244353

N,W=map(int,input().split())

DP=[[0,-1<<30] for i in range(20010+1)]
DP[10010]=[0,1]

for i in range(N):
    v,w=map(int,input().split())
    NDP=[[0,-1<<30] for i in range(20010+1)]
    for j in range(20010+1):
        NDP[j]=DP[j]

    for i in range(20010+1):
        if DP[i][1]<0:
            continue
        k,c=DP[i]

        v2=k+v

        if i+w<20010+1:
            if NDP[i+w][0]>v2:
                pass
            elif NDP[i+w][0]==v2:
                NDP[i+w][1]+=c
            else:
                NDP[i+w]=[v2,c]
    DP=NDP


#print(max(DP))

MAX=max(DP[:W+10010+1])[0]

ANS=0
for i in range(W+10010+1):
    if DP[i][0]==MAX:
        ANS+=DP[i][1]

print(MAX,ANS%mod)
                

0