結果
| 問題 | No.2866 yuusaan's Knapsack | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-08-30 23:04:56 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                MLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 552 bytes | 
| コンパイル時間 | 415 ms | 
| コンパイル使用メモリ | 82,268 KB | 
| 実行使用メモリ | 584,488 KB | 
| 最終ジャッジ日時 | 2024-08-30 23:05:00 | 
| 合計ジャッジ時間 | 4,470 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 3 MLE * 1 -- * 20 | 
ソースコード
N,W=map(int,input().split())
vs=[]
ws=[]
for _ in range(N):
    v,w=map(int,input().split())
    vs.append(v)
    ws.append(w)
from collections import defaultdict
dp=[defaultdict(int) for _ in range(2)]
j=0
dp[j][(0,0)]=1
for i in range(N):
    dp[1-j].clear()
    for (v,w),c in dp[j].items():
        dp[1-j][(v,w)]+=c
        dp[1-j][(v+vs[i],w+ws[i])]+=c
    j=1-j
val_cnt=defaultdict(int)
for (v,w),c in dp[j].items():
    if w<=W:
        val_cnt[v]+=c
        val_cnt[v]%=998244353
ans=sorted(val_cnt.items(), key=lambda x:-x[0])
print(*ans[0])
            
            
            
        