結果

問題 No.247 線形計画問題もどき
ユーザー tjaketjake
提出日時 2015-12-20 16:05:40
言語 Python2
(2.7.18)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 230 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 7,152 KB
実行使用メモリ 9,488 KB
最終ジャッジ日時 2023-10-17 14:28:40
合計ジャッジ時間 7,025 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
6,808 KB
testcase_01 AC 11 ms
6,512 KB
testcase_02 TLE -
testcase_03 AC 11 ms
6,508 KB
testcase_04 AC 11 ms
6,508 KB
testcase_05 AC 11 ms
6,508 KB
testcase_06 AC 11 ms
6,508 KB
testcase_07 AC 56 ms
7,072 KB
testcase_08 AC 46 ms
9,448 KB
testcase_09 AC 11 ms
6,508 KB
testcase_10 AC 13 ms
7,072 KB
testcase_11 AC 11 ms
6,508 KB
testcase_12 AC 11 ms
6,508 KB
testcase_13 AC 11 ms
6,508 KB
testcase_14 AC 11 ms
6,508 KB
testcase_15 AC 11 ms
6,508 KB
testcase_16 AC 11 ms
6,508 KB
testcase_17 AC 103 ms
6,544 KB
testcase_18 AC 41 ms
6,812 KB
testcase_19 AC 411 ms
6,808 KB
testcase_20 AC 729 ms
7,072 KB
testcase_21 AC 14 ms
6,576 KB
testcase_22 AC 48 ms
6,544 KB
testcase_23 AC 19 ms
6,600 KB
testcase_24 AC 802 ms
7,072 KB
testcase_25 AC 487 ms
6,808 KB
testcase_26 AC 92 ms
6,808 KB
testcase_27 AC 93 ms
6,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

c = input()
n = input()
a = map(int, raw_input().split())
dp = [c+1]*(c+1)
dp[0] = 0
ans = c+1
for e in a:
    for j in xrange(e, c+1):
        v=dp[j-e]+1
        if v<dp[j]:dp[j]=v
    if dp[c]<ans:ans=dp[c]
print-(ans>c)or ans
0