結果

問題 No.484 収穫
ユーザー mamekinmamekin
提出日時 2017-04-02 13:13:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,374 bytes
コンパイル時間 2,056 ms
コンパイル使用メモリ 108,112 KB
実行使用メモリ 222,132 KB
最終ジャッジ日時 2023-09-22 07:31:22
合計ジャッジ時間 10,885 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 6 ms
5,540 KB
testcase_10 AC 6 ms
5,616 KB
testcase_11 AC 6 ms
5,604 KB
testcase_12 AC 659 ms
221,900 KB
testcase_13 AC 662 ms
222,012 KB
testcase_14 AC 659 ms
221,888 KB
testcase_15 AC 646 ms
221,948 KB
testcase_16 AC 646 ms
221,964 KB
testcase_17 AC 650 ms
221,840 KB
testcase_18 AC 650 ms
221,880 KB
testcase_19 AC 645 ms
222,004 KB
testcase_20 AC 646 ms
221,840 KB
testcase_21 AC 638 ms
221,856 KB
testcase_22 WA -
testcase_23 AC 643 ms
221,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int INF = INT_MAX / 2;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    vector<vector<vector<int> > > dp(n, vector<vector<int> >(n, vector<int>(2, INF)));
    dp[0][n-1][0] = 0;
    dp[0][n-1][1] = 1;
    for(int len=n-1; len>0; --len){
        for(int i=0; i<n-len; ++i){
            int j = i + len;
            for(int k=0; k<2; ++k){
                int curr = (k == 0) ? i : j;
                int t1 = max(a[i], dp[i][j][k] + abs(curr - i)) + 1;
                dp[i+1][j][k] = min(dp[i+1][j][k], t1);
                int t2 = max(a[j], dp[i][j][k] + abs(curr - j)) + 1;
                dp[i][j-1][k] = min(dp[i][j-1][k], t2);
            }
        }
    }

    int ans = INF;
    for(int i=0; i<n; ++i){
        for(int j=0; j<2; ++j){
            ans = min(ans, max(a[i], dp[i][i][j]));
        }
    }
    cout << ans << endl;

    return 0;
}
0