Submission #849893

# Submission time Handle Problem Language Result Execution time Memory
849893 2023-09-15T14:16:42 Z MinaRagy06 Uplifting Excursion (BOI22_vault) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

int m;
ll l, a[605];
map<ll, ll> mem[605];
ll solve(int i, ll s) {
    if (i == 2 * m + 1) {
        if (s == l) return 0;
        return -1e18;
    }
    if (mem[i].find(s) != mem.end()) {
        return mem[i][s];
    }
    ll ans = -1e18;
    for (int j = 0; j <= a[i]; j++) {
        ans = max(ans, j + solve(i + 1, s + j * (i - m)));
    }
    return mem[i][s] = ans;
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> m >> l;
    for (int i = 0; i < 2 * m + 1; i++) {
        cin >> a[i];
    }
    ll ans = solve(0, 0);
    if (ans < 0) {
        cout << "impossible\n";
    } else {
        cout << ans << '\n';
    }
    return 0;
}

Compilation message

vault.cpp: In function 'll solve(int, ll)':
vault.cpp:13:31: error: request for member 'end' in 'mem', which is of non-class type 'std::map<long int, long int> [605]'
   13 |     if (mem[i].find(s) != mem.end()) {
      |                               ^~~