結果

問題 No.247 線形計画問題もどき
ユーザー TawaraTawara
提出日時 2015-07-19 00:11:53
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 323 bytes
コンパイル時間 1,730 ms
コンパイル使用メモリ 77,316 KB
実行使用メモリ 79,808 KB
最終ジャッジ日時 2023-09-21 17:27:42
合計ジャッジ時間 5,382 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
79,612 KB
testcase_01 AC 81 ms
79,004 KB
testcase_02 AC 82 ms
79,308 KB
testcase_03 AC 73 ms
76,320 KB
testcase_04 AC 73 ms
76,112 KB
testcase_05 AC 73 ms
76,272 KB
testcase_06 AC 73 ms
76,520 KB
testcase_07 AC 87 ms
79,644 KB
testcase_08 AC 82 ms
79,624 KB
testcase_09 AC 74 ms
76,412 KB
testcase_10 AC 80 ms
79,808 KB
testcase_11 AC 73 ms
76,620 KB
testcase_12 AC 74 ms
76,436 KB
testcase_13 AC 74 ms
76,336 KB
testcase_14 AC 74 ms
76,396 KB
testcase_15 AC 74 ms
76,492 KB
testcase_16 AC 74 ms
76,276 KB
testcase_17 AC 89 ms
78,984 KB
testcase_18 AC 86 ms
79,100 KB
testcase_19 AC 119 ms
79,520 KB
testcase_20 AC 107 ms
79,556 KB
testcase_21 AC 85 ms
78,992 KB
testcase_22 AC 87 ms
79,248 KB
testcase_23 AC 82 ms
79,260 KB
testcase_24 AC 107 ms
79,700 KB
testcase_25 AC 121 ms
79,460 KB
testcase_26 AC 89 ms
79,520 KB
testcase_27 AC 92 ms
79,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

C = int(raw_input())
N = int(raw_input())
a = sorted(list(set(map(int,raw_input().split(" ")))))
M = len(a)
UB = 10**5+1
dp = [UB for i in range(C+1)]
dp[0] = 0
for i in range(1,C+1):
	for j in range(M):
		if a[j] > i: 
			break
		if dp[i-a[j]] + 1 < dp[i]: 
			dp[i] = dp[i-a[j]] + 1
			
print -1 if dp[C] == UB else dp[C]
0