제출 #1010465

#제출 시각아이디문제언어결과실행 시간메모리
1010465vjudge1Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll r[212345],l[212345]; int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); ll n,c=1e10; cin>>n; ll a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=n-2;i>=0;i--){ r[i]=r[i+1]; if(a[i]<=a[i+1])r[i]=r[i+1]+max(0ll,a[i+1]-a[i]+1); } for(int i=1;i<n;i++){ l[i]=l[i-1]; if(a[i]<=a[i-1])l[i]+=max(0ll,a[i-1]-a[i]+1); } for(int i=0;i<n;i++){ c=min(c,max(r[i],l[i])); } cout<<c; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...