(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #1122178

#TimeUsernameProblemLanguageResultExecution timeMemory
1122178vjudge1Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
25 ms8696 KiB
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> #include <random> #include <bitset> #include <fstream> #include <array> #include <functional> #include <stack> #include <memory> #ifdef LOCAL #define _GLIBCXX_DEBUG #endif using namespace std; #define int long long #define app push_back #define all(x) x.begin(), x.end() #ifdef LOCAL #define debug(...) [](auto...a){ ((cout << a << ' '), ...) << endl; }(#__VA_ARGS__, ":", __VA_ARGS__) #define debugv(v) do { cout << #v << ": "; for (auto x : v) cout << x << ' '; cout << endl; } while(0) #else #define debug(...) #define debugv(v) #endif int32_t main() { cin.tie(0);ios_base::sync_with_stdio(0); int n; cin >> n; vector <int> a(n), d(n - 1), pre(n), suf(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } for (int i = 0; i + 1 < n; ++i) { d[i] = a[i + 1] - a[i]; pre[i + 1] = pre[i]; if (d[i] <= 0) { pre[i + 1] += 1 - d[i]; } } for (int i = n - 1; i > 0; --i) { suf[i - 1] = suf[i]; if (d[i - 1] >= 0) { suf[i - 1] += d[i - 1] + 1; } } int ans = 1e18; for (int i = 0; i < n; ++i) { ans = min(ans, max(pre[i] , suf[i])); } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...