結果

問題 No.484 収穫
ユーザー kotamanegikotamanegi
提出日時 2017-02-11 00:19:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,147 bytes
コンパイル時間 870 ms
コンパイル使用メモリ 95,728 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 10:35:57
合計ジャッジ時間 1,834 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 4 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 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]);
	cout << ans << endl;
	return 0;
}
0