結果
| 問題 | No.2866 yuusaan's Knapsack |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-30 22:50:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 519 bytes |
| 記録 | |
| コンパイル時間 | 168 ms |
| コンパイル使用メモリ | 82,400 KB |
| 実行使用メモリ | 713,952 KB |
| 最終ジャッジ日時 | 2024-08-30 22:50:38 |
| 合計ジャッジ時間 | 4,161 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 WA * 2 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(N+1)]
dp[0][(0,0)]=0
for i in range(N):
for (v,w),c in dp[i].items():
dp[i+1][(v,w)]=c
dp[i+1][(v+vs[i],w+ws[i])]+=1
val_cnt=defaultdict(int)
for (v,w),c in dp[N].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])