제출 #660812

#제출 시각아이디문제언어결과실행 시간메모리
660812culver0412Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
91 ms8496 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; long long int arr[n],brr[n-1]; for(int i=0;i<n;i++){ cin >> arr[i]; if(i>0){ brr[i-1]=arr[i]-arr[i-1]; } } long long int crr[n],drr[n]; crr[0]=0; drr[n-1]=0; for(int i=1;i<n;i++){ crr[i]=crr[i-1]+max(1-brr[i-1],0LL); } for(int i=n-2;i>=0;i--){ drr[i]=drr[i+1]+max(1+brr[i],0LL); } long long int ans=1000000000000000000; for(int i=0;i<=n-1;i++){ ans=min(ans,max(crr[i],drr[i])); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...