結果
| 問題 | No.247 線形計画問題もどき |
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2016-04-13 03:30:32 |
| 言語 | C++11(old_compat) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 399 bytes |
| 記録 | |
| コンパイル時間 | 1,189 ms |
| コンパイル使用メモリ | 169,772 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-08 16:06:10 |
| 合計ジャッジ時間 | 2,090 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 23 |
ソースコード
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int c, n; cin>>c>>n;
vector<int> a(n);
for(int& e: a) cin>>e;
vector<unsigned> dp(c+1, -1);
dp[c]=0;
for(int i=c; i>=0; --i)
for(int j=0; j<n; ++j)
if (i>=a[j] and ~dp[i])
dp[i-a[j]]=min(dp[i-a[j]], dp[i]+1);
cout<<(int)dp[0]<<endl;
}
hogeover30