Submission #541101

#TimeUsernameProblemLanguageResultExecution timeMemory
541101FystyGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
33 ms7072 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template<typename T> void _do(T x){cerr<<x<<"\n";} template<typename T,typename ...U> void _do(T x,U ...y){cerr<<x<<", ";_do(y...);} #define dbg(...) cerr<<#__VA_ARGS__<<" = ";_do(__VA_ARGS__); const ll INF=3e18; #define MottoHayaku ios::sync_with_stdio(false);cin.tie(0); //#define int ll #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define F first #define S second #define pb push_back ll a[200005],b[200005],suf[200005]; signed main() { MottoHayaku ll n; cin>>n; rep1(i,n) { cin>>a[i]; b[i]=a[i]-a[i-1]; } for(int i=n;i>=1;i--) { suf[i]=suf[i+1]+max(0LL,b[i]+1); } ll ans=INF,cur=0; rep(i,n+1) { ans=min(ans,max(cur,suf[i+1])); cur+=max(0LL,1-b[i+1]); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...