結果

問題 No.247 線形計画問題もどき
ユーザー Akisawa3Akisawa3
提出日時 2022-09-17 20:42:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 277 bytes
コンパイル時間 1,260 ms
コンパイル使用メモリ 86,616 KB
実行使用メモリ 76,540 KB
最終ジャッジ日時 2023-08-23 17:53:16
合計ジャッジ時間 6,163 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
76,120 KB
testcase_01 AC 81 ms
75,420 KB
testcase_02 AC 196 ms
76,540 KB
testcase_03 AC 74 ms
70,732 KB
testcase_04 AC 74 ms
70,736 KB
testcase_05 AC 73 ms
70,732 KB
testcase_06 AC 74 ms
71,040 KB
testcase_07 AC 84 ms
76,308 KB
testcase_08 AC 78 ms
76,244 KB
testcase_09 AC 74 ms
70,844 KB
testcase_10 AC 78 ms
76,084 KB
testcase_11 AC 73 ms
71,152 KB
testcase_12 AC 74 ms
71,120 KB
testcase_13 AC 75 ms
71,028 KB
testcase_14 AC 73 ms
71,084 KB
testcase_15 AC 75 ms
71,208 KB
testcase_16 AC 75 ms
71,160 KB
testcase_17 AC 96 ms
76,004 KB
testcase_18 AC 81 ms
75,936 KB
testcase_19 AC 135 ms
76,084 KB
testcase_20 AC 153 ms
76,328 KB
testcase_21 AC 83 ms
75,712 KB
testcase_22 AC 89 ms
75,812 KB
testcase_23 AC 87 ms
75,704 KB
testcase_24 AC 152 ms
76,260 KB
testcase_25 AC 124 ms
76,140 KB
testcase_26 AC 92 ms
75,900 KB
testcase_27 AC 98 ms
75,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [10**10] * (C+1)
dp[0] = 0

for i in range(N):
    for j in range(C):
        if j+A[i] <= C:
            dp[j+A[i]] = min(dp[j+A[i]], dp[j]+1)

if dp[C] == 10**10:
    print(-1)
else:
    print(dp[C])
0