제출 #908856

#제출 시각아이디문제언어결과실행 시간메모리
908856vjudge1Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; vector<int>vegetales(n); for(int i=0;i<n;i++){ cin>>vegetales[i]; } vector<int>a(n); a[0]=0; for(int i=1;i<n;i++){ a[i]=a[i-1]+max(0,vegetales[i-1]-vegetales[i]+1); } reverse(vegetales.begin(),vegetales.end()); vector<int>b(n); b[0]=0; for(int i=1;i<n;i++){ b[i]=b[i-1]+max(0,vegetales[i-1]-vegetales[i]+1); } int ans=INT_MAX; reverse(b.begin(),b.end()); for(int i=0;i<n;i++){ ans=min(ans,max(a[i],b[i])); } cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...