結果
問題 |
No.2866 yuusaan's Knapsack
|
ユーザー |
![]() |
提出日時 | 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 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 3 TLE * 1 -- * 21 |
ソースコード
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)