Submission #1091274

#TimeUsernameProblemLanguageResultExecution timeMemory
1091274kasdoBouquet (EGOI24_bouquet)C++14
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; #define int long long #define endl '\n' #define speed cin.tie (0) -> sync_with_stdio (0);ios_base::sync_with_stdio(false);cin.tie(0); const int maxn = 10005; int n; int l[maxn], r[maxn]; int rec(int i) { if (i <= 0) return 0; if (dp[i] != -1) return dp[i]; return dp[i] = max(rec(i - 1), rec(i - l[i]) + 1); } void s1() { cout<<rec(n - 1)<<endl; } void s2() { cout<<n / max(r[0], l[0])<<endl; } void solve() { int mx = 0; cin>>n; for(int i=0; i<n; i++) cin>>l[i]; for(int i=0; i<n; i++) { cin>>r[i]; mx = max(mx, r[i]); } if (mx == 0) s1(); else s2(); } signed main () { speed // freopen("feast.in", "r", stdin); // freopen("feast.out", "w", stdout); int _ = 1; // cin>>_; while(_--) solve(); return 0; }

Compilation message (stderr)

Main.cpp: In function 'long long int rec(long long int)':
Main.cpp:12:9: error: 'dp' was not declared in this scope
   12 |     if (dp[i] != -1) return dp[i];
      |         ^~
Main.cpp:14:12: error: 'dp' was not declared in this scope
   14 |     return dp[i] = max(rec(i - 1), rec(i - l[i]) + 1);
      |            ^~