結果
問題 |
No.247 線形計画問題もどき
|
ユーザー |
![]() |
提出日時 | 2015-12-20 16:05:40 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 1,748 ms / 2,000 ms |
コード長 | 230 bytes |
コンパイル時間 | 252 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 9,600 KB |
最終ジャッジ日時 | 2024-09-17 12:16:11 |
合計ジャッジ時間 | 5,930 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 23 |
ソースコード
c = input() n = input() a = map(int, raw_input().split()) dp = [c+1]*(c+1) dp[0] = 0 ans = c+1 for e in a: for j in xrange(e, c+1): v=dp[j-e]+1 if v<dp[j]:dp[j]=v if dp[c]<ans:ans=dp[c] print-(ans>c)or ans