結果

問題 No.247 線形計画問題もどき
ユーザー yaoshimaxyaoshimax
提出日時 2016-05-07 22:09:17
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 288 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 77,656 KB
実行使用メモリ 80,052 KB
最終ジャッジ日時 2023-09-21 17:37:52
合計ジャッジ時間 3,580 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
79,160 KB
testcase_01 AC 74 ms
77,476 KB
testcase_02 AC 189 ms
79,708 KB
testcase_03 AC 72 ms
76,392 KB
testcase_04 AC 75 ms
76,432 KB
testcase_05 AC 71 ms
76,284 KB
testcase_06 AC 72 ms
76,404 KB
testcase_07 AC 77 ms
79,560 KB
testcase_08 AC 77 ms
80,052 KB
testcase_09 AC 70 ms
76,452 KB
testcase_10 AC 72 ms
78,172 KB
testcase_11 AC 71 ms
76,152 KB
testcase_12 AC 71 ms
76,144 KB
testcase_13 AC 70 ms
76,416 KB
testcase_14 AC 72 ms
76,284 KB
testcase_15 AC 71 ms
76,476 KB
testcase_16 AC 71 ms
76,452 KB
testcase_17 AC 80 ms
79,272 KB
testcase_18 AC 84 ms
78,948 KB
testcase_19 AC 86 ms
79,712 KB
testcase_20 AC 98 ms
79,564 KB
testcase_21 AC 77 ms
78,792 KB
testcase_22 AC 80 ms
79,164 KB
testcase_23 AC 77 ms
79,112 KB
testcase_24 AC 99 ms
79,772 KB
testcase_25 AC 92 ms
79,324 KB
testcase_26 AC 82 ms
79,448 KB
testcase_27 AC 81 ms
79,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

C=int(raw_input())
N=int(raw_input())
A=map(int,raw_input().split())
A.sort()
A.reverse()
dp=[10000000 for i in range(C+1)]
dp[0]=0
for a in A:
    for j in range(a,C+1):
        if dp[j-a]>=0:
            dp[j]=min(dp[j],dp[j-a]+1)
if dp[C]==10000000:
    print -1
else:
    print dp[C]
0