結果
問題 |
No.2866 yuusaan's Knapsack
|
ユーザー |
![]() |
提出日時 | 2024-09-05 02:19:38 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 830 bytes |
コンパイル時間 | 327 ms |
コンパイル使用メモリ | 82,764 KB |
実行使用メモリ | 406,032 KB |
最終ジャッジ日時 | 2024-09-05 02:20:17 |
合計ジャッジ時間 | 5,386 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 TLE * 13 -- * 8 |
ソースコード
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)