제출 #1150455

#제출 시각아이디문제언어결과실행 시간메모리
1150455henriessGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n;cin >> n; vector<long long> A(n); for(int i = 0;i<n;i++){ cin >> A[i]; } //sequence has to be increasing then decreasing vector<long long> L(n); vector<long long> R(n); for(int i = 1;i<n;i++){ L[i] = L[i-1] + max(0LL,L[i-1]-L[i] + 1); } for(int i = n-2;i>=0;i--){ R[i] = R[i+1] + max(0LL,R[i+1] - R[i] + 1); } long long ans = LLONG_MAX; for(int i = 0;i<n;i++){ ans = min(ans,max(R[i],L[i])); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...