結果

問題 No.484 収穫
ユーザー tansunogontansunogon
提出日時 2017-05-05 19:17:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 980 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 68,420 KB
実行使用メモリ 34,896 KB
最終ジャッジ日時 2023-10-12 09:49:14
合計ジャッジ時間 2,097 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
34,816 KB
testcase_01 AC 10 ms
34,628 KB
testcase_02 AC 10 ms
34,740 KB
testcase_03 AC 11 ms
34,800 KB
testcase_04 AC 10 ms
34,684 KB
testcase_05 AC 10 ms
34,736 KB
testcase_06 AC 10 ms
34,688 KB
testcase_07 AC 10 ms
34,680 KB
testcase_08 AC 11 ms
34,676 KB
testcase_09 AC 11 ms
34,684 KB
testcase_10 AC 11 ms
34,632 KB
testcase_11 AC 11 ms
34,800 KB
testcase_12 AC 24 ms
34,636 KB
testcase_13 AC 24 ms
34,744 KB
testcase_14 AC 23 ms
34,688 KB
testcase_15 AC 24 ms
34,640 KB
testcase_16 AC 23 ms
34,632 KB
testcase_17 WA -
testcase_18 AC 23 ms
34,632 KB
testcase_19 AC 26 ms
34,752 KB
testcase_20 AC 24 ms
34,628 KB
testcase_21 AC 24 ms
34,868 KB
testcase_22 AC 23 ms
34,824 KB
testcase_23 AC 24 ms
34,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

struct iostream_init_struct
{ 
	iostream_init_struct()
	{
		std::cin.tie(0);
		std::cin.sync_with_stdio(false);
	}
} iostream_init;

#include <cstring>
#include <algorithm>

int N;
int A[2000];

int dp[2000][2000][2];
const int INF = 1e9;

int main(void)
{
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}

	memset(dp, 0x3f, sizeof dp);
	dp[0][N - 1][0] = A[0];
	dp[0][N - 1][1] = A[N - 1];

	for (int i = 0; i < N; ++i)
	{
		for (int j = N - 1; j >= i; --j)
		{
			if (i - 1 >= 0)
			{
				dp[i][j][0] = min(dp[i][j][0], max(A[i], dp[i - 1][j][0] + 1));
				dp[i][j][1] = min(dp[i][j][1], max(A[j], dp[i - 1][j][0] + j - (i - 1)));
			}
			if (j + 1 < N)
			{
				dp[i][j][0] = min(dp[i][j][0], max(A[i], dp[i][j + 1][1] + (j + 1) - i));
				dp[i][j][1] = min(dp[i][j][1], max(A[j], dp[i][j + 1][1] + 1));
			}
		}
	}

	int ans = INF;
	for (int i = 0; i < N; ++i)
	{
		ans = min(ans, dp[i][i][0]);
	}

	cout << ans << endl;
}
0