結果

問題 No.484 収穫
ユーザー latte0119latte0119
提出日時 2017-02-10 23:33:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 55 ms / 3,000 ms
コード長 1,300 bytes
コンパイル時間 1,067 ms
コンパイル使用メモリ 144,780 KB
実行使用メモリ 80,832 KB
最終ジャッジ日時 2023-08-03 16:17:57
合計ジャッジ時間 3,079 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
80,500 KB
testcase_01 AC 24 ms
80,568 KB
testcase_02 AC 24 ms
80,552 KB
testcase_03 AC 24 ms
80,560 KB
testcase_04 AC 25 ms
80,556 KB
testcase_05 AC 24 ms
80,488 KB
testcase_06 AC 24 ms
80,616 KB
testcase_07 AC 25 ms
80,500 KB
testcase_08 AC 24 ms
80,820 KB
testcase_09 AC 24 ms
80,616 KB
testcase_10 AC 24 ms
80,484 KB
testcase_11 AC 24 ms
80,696 KB
testcase_12 AC 54 ms
80,516 KB
testcase_13 AC 54 ms
80,564 KB
testcase_14 AC 54 ms
80,512 KB
testcase_15 AC 54 ms
80,832 KB
testcase_16 AC 53 ms
80,636 KB
testcase_17 AC 54 ms
80,524 KB
testcase_18 AC 54 ms
80,512 KB
testcase_19 AC 54 ms
80,628 KB
testcase_20 AC 55 ms
80,640 KB
testcase_21 AC 54 ms
80,496 KB
testcase_22 AC 54 ms
80,512 KB
testcase_23 AC 54 ms
80,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N;
int A[2222];

int dp[2222][2222][2];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];

    fill_n(**dp,2222*2222*2,INT_MAX);
    dp[0][N-1][0]=A[0];
    dp[0][N-1][1]=A[N-1];
    for(int len=N-1;len>0;len--){
        for(int i=0;i+len<N;i++){
            int j=i+len;
            int tmp;
            tmp=max(dp[i][j][0]+1,A[i+1]);
            chmin(dp[i+1][j][0],tmp);
            tmp=max(dp[i][j][0]+len,A[j]);
            chmin(dp[i+1][j][1],tmp);

            tmp=max(dp[i][j][1]+1,A[j-1]);
            chmin(dp[i][j-1][1],tmp);
            tmp=max(dp[i][j][1]+len,A[i]);
            chmin(dp[i][j-1][0],tmp);
        }
    }

    int ans=INT_MAX;
    for(int i=0;i<N;i++)rep(j,2)chmin(ans,dp[i][i][j]);
    cout<<ans<<endl;
    return 0;
}
0