結果

問題 No.484 収穫
ユーザー kotamanegikotamanegi
提出日時 2017-02-11 00:21:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,244 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 87,360 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 10:36:02
合計ジャッジ時間 1,647 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 800000000000000000
long long dp[300000] = {};
int main() {
#define int long long
	int n;
	cin >> n;
	vector<int> a;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	//左端に注目!
	int ans = LONG_INF;
	for (int teee = 0;teee < 2;++teee) {
		for (int i = 0;i < n + 1;++i) {
			if (i != 0) {
				if (i != 1)
					dp[i] = max(dp[i - 1] + 1, a[i - 1]);
				else dp[i] = a[i - 1];
			}
			else {
				dp[i] = 0;
			}
			//右端にGO
			if (i != n) {
				int pre_ans = dp[i] + (n - i - 1);
				for (int j = n - 1;j >= i;--j) {
					pre_ans = max(pre_ans + 1, a[j]);
				}
				ans = min(pre_ans, ans);
			}
		}
		ans = min(ans, dp[n]);
		reverse(a.begin(), a.end());
	}
	cout << ans << endl;
	return 0;
}
0