結果

問題 No.484 収穫
ユーザー sugim48sugim48
提出日時 2017-03-05 04:38:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 3,000 ms
コード長 1,464 bytes
コンパイル時間 1,107 ms
コンパイル使用メモリ 108,356 KB
実行使用メモリ 35,200 KB
最終ジャッジ日時 2024-04-21 14:29:58
合計ジャッジ時間 2,653 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 70 ms
35,072 KB
testcase_13 AC 71 ms
34,944 KB
testcase_14 AC 68 ms
35,200 KB
testcase_15 AC 69 ms
35,072 KB
testcase_16 AC 70 ms
34,944 KB
testcase_17 AC 69 ms
34,944 KB
testcase_18 AC 69 ms
34,944 KB
testcase_19 AC 68 ms
34,944 KB
testcase_20 AC 70 ms
34,944 KB
testcase_21 AC 68 ms
35,072 KB
testcase_22 AC 68 ms
35,072 KB
testcase_23 AC 69 ms
34,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <fstream>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };

const int MOD = 1000000007;
const int _MOD = 1000000009;
double EPS = 1e-10;
const int INF = INT_MAX / 2;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) cin >> a[i];
	vector<vector<int> > dpl(N + 1, vector<int>(N + 1, INF)), dpr = dpl;
	dpl[0][N] = dpr[0][N] = -1;
	for (int d = N; d >= 1; d--)
		for (int l = 0; l + d <= N; l++) {
			int r = l + d;
			dpl[l + 1][r] = min(dpl[l + 1][r], max(a[l], dpl[l][r] + 1));
			dpr[l][r - 1] = min(dpr[l][r - 1], max(a[r - 1], dpr[l][r] + 1));
			dpr[l][r - 1] = min(dpr[l][r - 1], max(a[r - 1], dpl[l][r] + r - l));
			dpl[l + 1][r] = min(dpl[l + 1][r], max(a[l], dpr[l][r] + r - l));
		}
	int ans = INF;
	rep(i, N) ans = min(ans, min(dpl[i][i], dpr[i][i]));
	cout << ans << endl;
}
0