結果

問題 No.247 線形計画問題もどき
ユーザー titiatitia
提出日時 2022-08-17 04:26:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 244 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 81,968 KB
実行使用メモリ 65,180 KB
最終ジャッジ日時 2024-04-14 21:28:48
合計ジャッジ時間 2,705 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
62,016 KB
testcase_01 AC 42 ms
60,252 KB
testcase_02 AC 76 ms
64,056 KB
testcase_03 AC 36 ms
52,560 KB
testcase_04 AC 36 ms
52,892 KB
testcase_05 AC 36 ms
52,824 KB
testcase_06 AC 36 ms
52,740 KB
testcase_07 AC 49 ms
64,088 KB
testcase_08 AC 42 ms
59,828 KB
testcase_09 AC 36 ms
52,068 KB
testcase_10 AC 40 ms
59,028 KB
testcase_11 AC 35 ms
52,684 KB
testcase_12 AC 37 ms
51,748 KB
testcase_13 AC 35 ms
52,148 KB
testcase_14 AC 36 ms
52,404 KB
testcase_15 AC 36 ms
52,864 KB
testcase_16 AC 36 ms
53,320 KB
testcase_17 AC 62 ms
62,344 KB
testcase_18 AC 45 ms
62,096 KB
testcase_19 AC 91 ms
62,608 KB
testcase_20 AC 99 ms
63,456 KB
testcase_21 AC 43 ms
60,004 KB
testcase_22 AC 46 ms
60,008 KB
testcase_23 AC 44 ms
60,780 KB
testcase_24 AC 102 ms
65,180 KB
testcase_25 AC 74 ms
62,852 KB
testcase_26 AC 52 ms
62,160 KB
testcase_27 AC 50 ms
61,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

C=int(input())
N=int(input())
A=list(map(int,input().split()))

DP=[1<<31]*(C+1)
DP[C]=0

for i in range(C,-1,-1):
    for a in A:
        if i>=a:
            DP[i-a]=min(DP[i-a],DP[i]+1)

if DP[0]==1<<31:
    print(-1)
else:
    print(DP[0])
0