Submission #677009

#TimeUsernameProblemLanguageResultExecution timeMemory
677009rittin1Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int arr[n+1]; for(int i=1;i<=n;i++){ cin >> arr[i]; } dp1[n+1]; dp2[n+1]; dp1[1]=0; for(int i=2;i<=n;i++){ dp1[i]=dp1[i-1]; if(arr[i]<=arr[i-1]){ dp1[i]+=arr[i-1]-arr[i]+1; } } dp2[n]=0; for(int i=n-1;i>=1;i--){ dp2[i]=dp2[i+1]; if(arr[i]<=arr[i+1]){ dp2[i]+=arr[i+1]-arr[i]+1; } } int ans=max(dp1[1],dp2[1]); for(int i=2;i<=n;i++){ ans=min(ans,max(dp1[i],dp2[i])); } cout << ans; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:14:5: error: 'dp1' was not declared in this scope
   14 |     dp1[n+1];
      |     ^~~
Main.cpp:15:5: error: 'dp2' was not declared in this scope
   15 |     dp2[n+1];
      |     ^~~