結果

問題 No.247 線形計画問題もどき
ユーザー TwizzTwizz
提出日時 2017-05-25 19:09:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 684 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 159,576 KB
実行使用メモリ 47,512 KB
最終ジャッジ日時 2023-10-19 23:19:54
合計ジャッジ時間 6,026 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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][100002] = {};

int dfs(int i, int j) {
	if (i == n)return mod;
	if (j == 0)return 0;
	if (dp[i][j] < mod)return dp[i][j];
	for (int l = 0; j - l*a[i] >= 0; l++) {
		dp[i][j] = min(dp[i][j], l+dfs(i + 1, j - l*a[i]));
	}
	return dp[i][j];
}

int main() {
	REP(i, 102)REP(j, 100002)dp[i][j] = mod;
	cin >> c; cin >> n;
	REP(i, n)cin >> a[i];
	print(dfs(0, c));
	return 0;
}
0