제출 #1161249

#제출 시각아이디문제언어결과실행 시간메모리
1161249brintonGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
100 / 100
14 ms4248 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ cin.tie(0); ios_base::sync_with_stdio(0); //start here int N; cin >> N; vector<int> v(N); for(auto &i:v)cin >> i; vector<int> diff; for(int i = 1;i < N;i++){ diff.push_back(v[i]-v[i-1]); } // for(auto i:diff)cout << i << " ";cout << endl; int front = 0; int back = 0; for(auto i:diff){ back += max(0LL,i-(-1)); } int minAns = back; for(auto i:diff){ back -= max(0LL,i-(-1)); front += max(0LL,1-i); // cout << back << " " << front << " " << max(back,front) << endl; minAns = min(minAns,max(back,front)); // cout << minAns << endl; } cout << minAns; } /* 8 12 2 34 85 4 91 29 85 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...