結果

問題 No.484 収穫
ユーザー rapurasurapurasu
提出日時 2017-02-12 22:07:48
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,632 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 145,000 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 14:55:35
合計ジャッジ時間 5,512 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 319 ms
4,380 KB
testcase_13 AC 346 ms
4,376 KB
testcase_14 AC 262 ms
4,380 KB
testcase_15 AC 324 ms
4,376 KB
testcase_16 AC 358 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 60 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 277 ms
4,380 KB
testcase_23 AC 422 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int A[2001];

bool check(LL x){
   bool ans=false;
   bool check[2001];
   //終了位置をiとする
   REP(i,N){
       if(x<A[i])continue;
       //右→左	
       REP(j,N){
           check[j]=false;
       }
       check[i]=true;
       REP(j,i){
           if(A[j]<=x-i+j)check[j]=true;
       }
       for(int j=i+1;j<N;j++){
           if(A[j]<=x-i-j)check[j]=true;
       }
       bool c=true;
       REP(j,N){
           if(check[j]==false){
              c=false;
              break;
           }
       }
       if(c){
          ans=c;
          break;
       }
       
       //左→右	
       REP(j,N){
           check[j]=false;
       }
       check[i]=true;
       REP(j,i){
           if(A[j]<=x-(N-1-i)-(N-1)+j)check[j]=true;
       }
       for(int j=i+1;j<N;j++){
           if(A[j]<=x-(j-i))check[j]=true;
       }
       c=true;
       REP(j,N){
           if(check[j]==false){
              c=false;
              break;
           }
       }
       if(c){
          ans=c;
          break;
       }
   }
   return ans;
}

LL binary_search(){
   LL ub=-1;
   LL lb=1000000001;
   while(lb-ub!=1){
      LL mid=(ub+lb)/2;
      if(check(mid)){
         lb=mid;
      }else{
         ub=mid;
      }
   }
   return lb;
}



int main(){
	cin>>N;
	REP(i,N){
	    cin>>A[i];
	}
	//cout<<check(2)<<endl;
        cout<<binary_search()<<endl;
	return(0);
}
0