結果

問題 No.247 線形計画問題もどき
コンテスト
ユーザー vain0
提出日時 2015-07-17 23:29:19
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,224 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 452 ms
コンパイル使用メモリ 86,480 KB
最終ジャッジ日時 2026-03-29 01:29:53
合計ジャッジ時間 852 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:40:19: error: aggregate 'std::array<int, 100003> dp' has incomplete type and cannot be defined
   40 | array<int, C_MAX> dp;
      |                   ^~
main.cpp:15:1: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>'
   14 | #include <iostream>
  +++ |+#include <array>
   15 | #include <cstdio>

ソースコード

diff #
raw source code

#include <cassert>
#include <functional>
#include <set>
#include <ctime>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#ifndef ONLINE_JUDGE //POJ
# include <complex>
# include <random>
# include <array>
# define mkt make_tuple
# define empb emplace_back
#endif
#ifdef _LOCAL
# include "for_local.h"
#else
# define debug if (false)
#endif
using namespace std;
typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull;
#define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I))
#define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I))
#define mkp make_pair
#define all(_X) (_X).begin(), (_X).end()

vector<int> as;
int c;
int n;

static int const C_MAX = 100003, N_MAX = 100;
array<int, C_MAX> dp;

int const INF = 1<<29;

signed main()
{
	fill(all(dp), INF);
	dp[0] = 0;

	cin >> c >> n;
	rep(i, n)
	{
		int a;
		cin >> a;
		as.push_back(a);
	}

	rep(ci, c)
	{
		rep(ni, n)
		{
			int const c2 = ci + as[ni];
			if ( c2 > C_MAX ) continue;

			dp[c2] = min(dp[c2], dp[ci] + 1);
		}
	}

	if ( dp[c] == INF ) dp[c] = -1;
	cout << dp[c] << endl;

	return 0;
}
0