Submission #736391

#TimeUsernameProblemLanguageResultExecution timeMemory
736391shoryu386Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
40 / 100
1074 ms1740 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n; int arr[200007]; int solve(int tp){ int linc = 0; for (int x = 1; x <= tp; x++){ if (arr[x-1] >= arr[x]){ //enforce an increase linc += arr[x-1] - arr[x] + 1; } } int rinc = 0; for (int x = n-2; x >= tp; x--){ if (arr[x+1] >= arr[x]){ //enforce an increase rinc += arr[x+1] - arr[x] + 1; } } //cout << tp << ' ' << linc << ' ' << rinc << '\n'; return max(linc, rinc); } main(){ cin >> n; for (int x = 0; x < n; x++) cin >> arr[x]; int ans = LLONG_MAX/100; for (int x = 0; x < n; x++) ans = min(ans, solve(x)); cout << ans; }

Compilation message (stderr)

Main.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...