結果

問題 No.5 数字のブロック
ユーザー わん
提出日時 2025-10-20 15:42:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 702 ms / 5,000 ms
コード長 235 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 82,352 KB
実行使用メモリ 66,804 KB
最終ジャッジ日時 2025-10-20 15:42:57
合計ジャッジ時間 6,960 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

L = int(input())
N = int(input())
W = list(map(int, input().split()))

INF = 1<<60
dp = [-INF]*(L+1)
dp[0] = 0
for w in W:
  for i in range(L+1)[::-1]:
    if i+w<=L and dp[i+w]<dp[i]+1:
      dp[i+w] = dp[i]+1
ans = max(dp)
print(ans)
0