結果

問題 No.5 数字のブロック
ユーザー HydruHydru
提出日時 2023-01-15 14:44:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 822 ms / 5,000 ms
コード長 254 bytes
コンパイル時間 398 ms
コンパイル使用メモリ 86,828 KB
実行使用メモリ 76,824 KB
最終ジャッジ日時 2023-08-27 22:18:33
合計ジャッジ時間 9,290 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,284 KB
testcase_01 AC 72 ms
71,252 KB
testcase_02 AC 79 ms
71,588 KB
testcase_03 AC 449 ms
76,672 KB
testcase_04 AC 85 ms
76,676 KB
testcase_05 AC 504 ms
76,500 KB
testcase_06 AC 240 ms
76,308 KB
testcase_07 AC 308 ms
76,556 KB
testcase_08 AC 220 ms
76,296 KB
testcase_09 AC 136 ms
76,524 KB
testcase_10 AC 298 ms
76,548 KB
testcase_11 AC 137 ms
76,824 KB
testcase_12 AC 416 ms
76,684 KB
testcase_13 AC 297 ms
76,296 KB
testcase_14 AC 90 ms
76,100 KB
testcase_15 AC 81 ms
76,432 KB
testcase_16 AC 456 ms
76,360 KB
testcase_17 AC 673 ms
76,584 KB
testcase_18 AC 391 ms
76,652 KB
testcase_19 AC 822 ms
76,364 KB
testcase_20 AC 74 ms
75,872 KB
testcase_21 AC 75 ms
71,460 KB
testcase_22 AC 71 ms
71,392 KB
testcase_23 AC 78 ms
71,076 KB
testcase_24 AC 83 ms
76,428 KB
testcase_25 AC 107 ms
76,456 KB
testcase_26 AC 70 ms
71,352 KB
testcase_27 AC 72 ms
75,116 KB
testcase_28 AC 75 ms
75,296 KB
testcase_29 AC 92 ms
76,820 KB
testcase_30 AC 106 ms
76,420 KB
testcase_31 AC 73 ms
75,152 KB
testcase_32 AC 78 ms
75,180 KB
testcase_33 AC 70 ms
71,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

l=int(input())
n=int(input())
W=list(map(int,input().split()))

DP=[-1]*(l+1)
DP[0]=0
DP[W[0]]=1

for i in range(1,n):
    for j in range(l-W[i],-1,-1):
        if DP[j]==-1:
            continue
        DP[j+W[i]]=max(DP[j+W[i]],DP[j]+1)

print(max(DP))
0