結果

問題 No.247 線形計画問題もどき
コンテスト
ユーザー ああ
提出日時 2026-05-18 21:51:36
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 279 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 334 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 63,616 KB
最終ジャッジ日時 2026-05-18 21:51:45
合計ジャッジ時間 2,595 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

c,n=int(input()),int(input())
a=list(map(int,input().split()))
dp=[1<<30]*(c+1);dp[0]=0
for i in range(c):
    if dp[i]==1<<30:
        continue
    for j in a:
        if i+j<=c:
            dp[i+j]=min(dp[i+j],dp[i]+1)
if dp[-1]==1<<30:
    print(-1)
else:
    print(dp[-1])
  
0