제출 #493785

#제출 시각아이디문제언어결과실행 시간메모리
493785nathanlee726Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
26 ms5392 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define int ll #define pii pair<int,int> #define X first #define Y second #define F(n) Fi(i,n) #define Fi(i,n) Fl(i,0,n) #define Fl(i,l,n) for(int i=l;i<n;i++) #define all(x) x.begin(),x.end() #define sz(x) ((int)x.size()) #define abs(x) ((x)>0?(x):-(x)) #define pb push_back int a[200010],b[200010]; signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n; cin>>n; F(n)cin>>a[i]; F(n-1)b[i]=a[i+1]-a[i]; int s0=0,s1=0; F(n-1)if(b[i]>=0)s1+=(b[i]+1); int an=1e18; an=min(an,max(s0,s1)); //F(n-1)cout<<b[i]<<" "; //cout<<endl; F(n-1){ if(b[i]>0){ s1-=(b[i]+1); } else if(b[i]==0){ s1--; s0++; } else{ s0-=(b[i]-1); } an=min(an,max(s0,s1)); } cout<<an<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...