제출 #493786

#제출 시각아이디문제언어결과실행 시간메모리
493786PixelCatGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
26 ms5160 KiB
#include <bits/stdc++.h> #define For(i,a,b) for(int i=a;i<=b;i++) #define Forr(i,a,b) for(int i=a;i>=b;i--) #define F first #define S second #define all(x) x.begin(),x.end() #define sz(x) ((int)x.size()) #define eb emplace_back #define INF (1000000000000000ll); #define int ll using namespace std; using ll=long long; using pii=pair<int,int>; int a[200020]; int l[200020]; int r[200020]; int32_t main(){ ios::sync_with_stdio(false); cin.tie(0); // nachoneko sama & miku sama bless me >/////< int n; cin>>n; For(i,1,n) cin>>a[i]; For(i,2,n) l[i]=l[i-1]+max(0ll,a[i-1]-a[i]+1); Forr(i,n-1,1) r[i]=r[i+1]+max(0ll,a[i+1]-a[i]+1); int ans=INF; For(i,1,n) ans=min(ans,max(l[i],r[i])); cout<<ans<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...