結果
問題 | No.2866 yuusaan's Knapsack |
ユーザー | titia |
提出日時 | 2024-09-05 02:25:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 543 ms / 2,000 ms |
コード長 | 815 bytes |
コンパイル時間 | 350 ms |
コンパイル使用メモリ | 82,420 KB |
実行使用メモリ | 248,296 KB |
最終ジャッジ日時 | 2024-09-05 02:25:17 |
合計ジャッジ時間 | 11,931 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 91 ms
91,304 KB |
testcase_01 | AC | 82 ms
89,304 KB |
testcase_02 | AC | 124 ms
92,060 KB |
testcase_03 | AC | 53 ms
70,752 KB |
testcase_04 | AC | 53 ms
70,844 KB |
testcase_05 | AC | 80 ms
70,484 KB |
testcase_06 | AC | 524 ms
243,908 KB |
testcase_07 | AC | 406 ms
209,272 KB |
testcase_08 | AC | 500 ms
236,564 KB |
testcase_09 | AC | 452 ms
230,748 KB |
testcase_10 | AC | 505 ms
236,336 KB |
testcase_11 | AC | 358 ms
190,288 KB |
testcase_12 | AC | 440 ms
221,216 KB |
testcase_13 | AC | 404 ms
201,288 KB |
testcase_14 | AC | 448 ms
220,744 KB |
testcase_15 | AC | 472 ms
238,072 KB |
testcase_16 | AC | 434 ms
202,580 KB |
testcase_17 | AC | 460 ms
227,200 KB |
testcase_18 | AC | 350 ms
184,052 KB |
testcase_19 | AC | 543 ms
246,572 KB |
testcase_20 | AC | 433 ms
209,392 KB |
testcase_21 | AC | 470 ms
221,132 KB |
testcase_22 | AC | 414 ms
210,328 KB |
testcase_23 | AC | 535 ms
248,296 KB |
testcase_24 | AC | 439 ms
209,524 KB |
testcase_25 | AC | 467 ms
228,604 KB |
testcase_26 | AC | 521 ms
243,816 KB |
testcase_27 | AC | 91 ms
90,808 KB |
ソースコード
import sys input = sys.stdin.readline mod=998244353 N,W=map(int,input().split()) DP=[[-1<<30,-1<<30] for i in range(50010)] DP[10010]=[0,1] for i in range(N): v,w=map(int,input().split()) NDP=[[-1<<30,-1<<30] for i in range(50010)] for j in range(50010): NDP[j][0],NDP[j][1]=DP[j][0],DP[j][1] for j in range(50010): if DP[j][1]<0: continue k,c=DP[j] v2=k+v if j+w<50010: 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)