제출 #466111

#제출 시각아이디문제언어결과실행 시간메모리
466111pdstiagoGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
34 ms6948 KiB
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define mxn 200005 #define mxm 105 #define f first #define s second #define pb push_back #define es " " #define endl '\n' #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3f #define ll long long #define fastio ios_base::sync_with_stdio(0), cin.tie(0) #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() typedef pair<string, string> pii; typedef pair<int, pii> pip; int n; ll resp=INFL, prefix[mxn], suff[mxn], v[mxn]; int main(){ fastio; cin >> n; for(int i=1; i<=n; i++){ cin >> v[i]; } for(int i=1; i<=n; i++){ prefix[i]=prefix[i-1]+max(0LL, v[i-1]-v[i]+1); } for(int i=n; i>=1; i--){ suff[i]=suff[i+1]+max(0LL, v[i+1]-v[i]+1); } for(int i=1; i<=n; i++){ resp=min(resp, max(prefix[i], suff[i])); } cout << resp; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...