結果

問題 No.5 数字のブロック
ユーザー Ryushi-tech
提出日時 2020-06-26 21:32:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 324 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 65,664 KB
最終ジャッジ日時 2024-07-04 19:48:05
合計ジャッジ時間 7,233 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [-1] * (l+1)
dp[0] = 0

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

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