結果

問題 No.5 数字のブロック
ユーザー Ryushi-tech
提出日時 2020-06-26 21:21:57
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 293 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 428,928 KB
最終ジャッジ日時 2024-07-04 19:30:35
合計ジャッジ時間 6,978 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 RE * 1 TLE * 1 -- * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ma = W[-1]
m = ma * n + 1
dp = [-1] * m
dp[0] = 0

for w in W:
    for i in range(m - 1, -1, -1):
        if dp[i] >= 0:
            dp[i + w] = max(dp[i] + 1, dp[i + w])

print(max(dp[:l - 1]))
#print(dp[:l - 1])
0