結果

問題 No.247 線形計画問題もどき
ユーザー 👑 rin204rin204
提出日時 2022-07-08 09:35:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 245 bytes
コンパイル時間 885 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 76,728 KB
最終ジャッジ日時 2023-08-27 02:22:44
合計ジャッジ時間 4,510 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
76,256 KB
testcase_01 AC 68 ms
75,912 KB
testcase_02 AC 123 ms
76,656 KB
testcase_03 AC 66 ms
71,240 KB
testcase_04 AC 65 ms
71,488 KB
testcase_05 AC 68 ms
71,072 KB
testcase_06 AC 65 ms
71,356 KB
testcase_07 AC 69 ms
76,716 KB
testcase_08 AC 69 ms
76,384 KB
testcase_09 AC 66 ms
71,320 KB
testcase_10 AC 65 ms
72,160 KB
testcase_11 AC 66 ms
71,504 KB
testcase_12 AC 64 ms
71,256 KB
testcase_13 AC 66 ms
71,560 KB
testcase_14 AC 65 ms
71,264 KB
testcase_15 AC 66 ms
71,404 KB
testcase_16 AC 65 ms
71,272 KB
testcase_17 AC 74 ms
76,040 KB
testcase_18 AC 71 ms
76,068 KB
testcase_19 AC 76 ms
76,396 KB
testcase_20 AC 90 ms
76,520 KB
testcase_21 AC 69 ms
75,668 KB
testcase_22 AC 70 ms
75,708 KB
testcase_23 AC 70 ms
76,124 KB
testcase_24 AC 90 ms
76,728 KB
testcase_25 AC 85 ms
76,624 KB
testcase_26 AC 72 ms
76,328 KB
testcase_27 AC 68 ms
76,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

C = int(input())
n = int(input())
A = list(map(int, input().split()))
dp = [1 << 30] * (C + 1)
dp[0] = 0
for a in A:
    for i in range(a, C + 1):
        dp[i] = min(dp[i], dp[i - a] + 1)
ans = dp[-1]
if ans == 1 << 30:
    ans = -1
print(ans)
0