結果

問題 No.247 線形計画問題もどき
コンテスト
ユーザー tnoda_
提出日時 2015-09-10 10:40:48
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
AC  
実行時間 123 ms / 2,000 ms
+ 760µs
コード長 293 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 81 ms
コンパイル使用メモリ 62,332 KB
実行使用メモリ 71,812 KB
最終ジャッジ日時 2026-10-15 02:31:25
合計ジャッジ時間 4,487 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

C = input()
N = input()
A = map(int, raw_input().split())
dp = [-1] * (10 ** 6)
dp[0] = 0
for i in xrange(C):
    if dp[i] == -1:
        continue
    for a in A:
        if dp[i+a] == -1:
            dp[i+a] = dp[i] + 1
        else:
            dp[i+a] = min(dp[i+a], dp[i] + 1)
print(dp[C])
0