結果

問題 No.484 収穫
ユーザー mamekinmamekin
提出日時 2017-04-02 13:14:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,374 bytes
コンパイル時間 1,209 ms
コンパイル使用メモリ 108,488 KB
実行使用メモリ 222,092 KB
最終ジャッジ日時 2023-09-22 14:08:46
合計ジャッジ時間 9,798 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 6 ms
5,480 KB
testcase_10 AC 6 ms
5,512 KB
testcase_11 AC 5 ms
5,612 KB
testcase_12 AC 617 ms
221,816 KB
testcase_13 AC 625 ms
221,760 KB
testcase_14 AC 607 ms
221,760 KB
testcase_15 AC 614 ms
221,944 KB
testcase_16 AC 608 ms
221,812 KB
testcase_17 AC 619 ms
221,932 KB
testcase_18 AC 619 ms
222,000 KB
testcase_19 AC 613 ms
221,760 KB
testcase_20 AC 607 ms
221,772 KB
testcase_21 AC 609 ms
221,812 KB
testcase_22 WA -
testcase_23 AC 616 ms
221,932 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] = 0;
    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