Submission #894215

#TimeUsernameProblemLanguageResultExecution timeMemory
894215boxGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
20 ms6244 KiB
#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; x = a[i++]) l[i] = max(0, x - a[i] + 1) + (i > 0 ? l[i - 1] : 0); for (int i = n - 1, x = 0; i >= 0; x = a[i--]) r[i] = max(0, x - a[i] + 1) + (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:8:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
Main.cpp:10:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   for (int i = 0; i < n; i++) scanf("%d", &a[i]);
      |                               ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...