結果

問題 No.484 収穫
ユーザー btkbtk
提出日時 2017-02-11 12:01:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 118 ms / 3,000 ms
コード長 1,389 bytes
コンパイル時間 1,677 ms
コンパイル使用メモリ 169,892 KB
実行使用メモリ 66,048 KB
最終ジャッジ日時 2024-04-21 14:27:27
合計ジャッジ時間 3,857 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 114 ms
66,048 KB
testcase_13 AC 116 ms
65,920 KB
testcase_14 AC 115 ms
65,920 KB
testcase_15 AC 117 ms
65,920 KB
testcase_16 AC 116 ms
66,048 KB
testcase_17 AC 116 ms
66,048 KB
testcase_18 AC 116 ms
66,048 KB
testcase_19 AC 117 ms
65,920 KB
testcase_20 AC 118 ms
65,920 KB
testcase_21 AC 117 ms
66,048 KB
testcase_22 AC 117 ms
66,048 KB
testcase_23 AC 116 ms
66,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define DEBUG if(0)
using namespace std;

typedef long long LL;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
    cout<<fixed;
    cout<<setprecision(10);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define fi first
#define se second
#define pb push_back

template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<LL> V;
typedef vector<V> VV;
const LL INF=1e16;
int main(){
    int N;
    cin>>N;
    V A(N);cin>>A;
    VV L(N+2,V(N+2,INF));
    VV R(N+2,V(N+2,INF));
    L[2][N]=A[0];
    R[1][N-1]=A[N-1];
    for(int len=N-2;len>=0;len--){
        for(int l=0;l+len<N;l++){
            int r=l+len;
            DEBUG printf("L[%d][%d]=%lld\n",l,r,L[l+1][r+1]);
            DEBUG printf("R[%d][%d]=%lld\n",l,r,R[l+1][r+1]);
            chmin(L[l+2][r+1],max(L[l+1][r+1]+1,A[l]));
            chmin(R[l+1][r],max(L[l+1][r+1]+r-l+1,A[r]));
            chmin(L[l+2][r+1],max(R[l+1][r+1]+r-l+1,A[l]));
            chmin(R[l+1][r],max(R[l+1][r+1]+1,A[r]));
        }
    }
    LL res=INF;
    REP(i,N+1)chmin(res,L[i+1][i]);
    REP(i,N+1)chmin(res,R[i+1][i]);
    cout<<res<<endl;
    return 0;
}
0