Submission #530277

#TimeUsernameProblemLanguageResultExecution timeMemory
530277Tw_28e7Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
0 ms204 KiB
#include <bits/stdc++.h> #include <ext/rope> using namespace __gnu_cxx; using namespace std; #define LL long long #define pLL pair<long long, long long> #define F first #define S second #define pb push_back #define rz resize #define all(x) x.begin(), x.end() //#define cin fin void Star_Brust_Stream() { ios_base::sync_with_stdio(false); cin.tie(0); return; } const LL INF = 1e18; const LL MOD = 1e9 + 7; int main() { Star_Brust_Stream(); LL n; cin >> n; vector<LL> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } LL l = 0, r = n - 1; LL cnt = 0; while (l < r) { while (v[l] < v[l + 1]) { l++; } while (v[r - 1] > v[r]) { r--; } cnt += min(v[l] - v[l + 1], v[r] - v[r - 1]) + 1; l++; r--; } cout << cnt << endl; // system("pause"); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...