結果

問題 No.247 線形計画問題もどき
ユーザー TwizzTwizz
提出日時 2017-05-25 19:19:44
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 555 bytes
コンパイル時間 1,307 ms
コンパイル使用メモリ 159,416 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 23:20:00
合計ジャッジ時間 4,459 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 WA -
testcase_02 RE -
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,348 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 2 ms
4,348 KB
testcase_10 RE -
testcase_11 AC 2 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 WA -
testcase_17 RE -
testcase_18 WA -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include"bits/stdc++.h"

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
const ll mod = 100000000;

int c, n, a[102];
int dp[102] = {};


int main() {
	REP(i, 102)REP(j, 100002)dp[i] = mod;
	cin >> c; cin >> n;
	REP(i, n)cin >> a[i];
	dp[0] = 0;
	REP(i, c+1) {
		REP(j, n) {
			dp[i] = min(dp[i],dp[i - a[j]]+1);
		}
	}
	int ans = dp[c] == mod ? -1 : dp[c];
	print(ans);
}
0