Submission #503329

# Submission time Handle Problem Language Result Execution time Memory
503329 2022-01-07T16:31:18 Z WongChun1234 Growing Vegetables is Fun 4 (JOI21_ho_t1) C++14
0 / 100
1 ms 332 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=200050;
int n,a[MAXN],frnt[MAXN],bck[MAXN],curr,cb=INT_MAX;
int main(){
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	curr=a[1];
	for (int i=2;i<=n;i++){
		curr=max(curr+1,a[i]);
		frnt[i]=max(frnt[i-1],curr-a[i]);
	}
	curr=a[n];
	for (int i=n-1;i>=1;i--){
		curr=max(curr+1,a[i]);
		bck[i]=max(bck[i+1],curr-a[i]);
	}
	for (int i=1;i<=n;i++) cb=min(cb,max(frnt[i],bck[i]));
	cout<<cb<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Incorrect 1 ms 332 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Incorrect 1 ms 332 KB Output isn't correct
6 Halted 0 ms 0 KB -