Submission #639852

#TimeUsernameProblemLanguageResultExecution timeMemory
639852PikachudoraEHEGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
0 / 100
8 ms336 KiB
#include<bits/stdc++.h> using namespace std; int h[201000]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n;cin>>n; for(int i=0;i<n;i++){ cin>>h[i]; } int mini = INT_MAX; for(int i=0;i<n;i++){ //peak = i position int x[n];x[0]=0; for(int j=1;j<=i;j++){ x[j] = x[j-1] + max(h[j-1]-h[j]+1,0); } int y[n];y[n-1]=0; for(int j=n-2;j>=i;j--){ y[j] = y[j+1] + max(h[j+1]-h[j]+1,0); } int maxy = max(x[i],y[i]); if(mini>maxy)mini = maxy; } cout<<mini; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...