Submission #694149

#TimeUsernameProblemLanguageResultExecution timeMemory
694149bdlGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
1 ms324 KiB
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <iostream> using namespace std; const int N = 2e5; int main() { int n; scanf("%d", &n); static int a[N]; for (int i = 0; i < n; i++) scanf("%d", &a[i]); static long long l[N], r[N]; for (int i = 0, x = 0; i < n; i++) { x = max(x + 1, a[i]); l[i] = x - a[i] + (i > 0 ? l[i - 1] : 0); } for (int i = n - 1, x = 0; i >= 0; i--) { x = max(x + 1, a[i]); r[i] = x - a[i] + (i < n - 1 ? r[i + 1] : 0); } long long x = 1e18; for (int i = 0; i < n; i++) x = min(x, max(l[i], r[i])); printf("%lld\n", x); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
Main.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d", &a[i]);
      |     ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...