結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod=998244353

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

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

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

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

        v2=k+v

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

    print(DP[10010:10015])


#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