Submission #697803

# Submission time Handle Problem Language Result Execution time Memory
697803 2023-02-11T06:15:19 Z Duy_e Uplifting Excursion (BOI22_vault) C++14
0 / 100
3 ms 3540 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair <ll, ll>
#define st first
#define nd second
#define rep(i, n, m) for (ll i = (n); i <= (m); i ++)
#define rrep(i, n, m) for (ll i = (n); i >= (m); i --)
using namespace std;

const long long INF = 1e18;
const long long N = 2e5;

ll n, m, a[N], l;

ll buff;
ll dp[N];

void maximize(ll &x, ll y) {
    if (x < y) x = y;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> m >> l;
    ll tot = 0;
    rep(i, 1, 2 * m + 1) {
        cin >> a[i];
        if (i > m) tot += a[i] * (i - m - 1);
    }

    if (tot < l) return cout << "impossible\n", 0;

    buff = abs(l);

    rep(i, 0, N - 1) dp[i] = -1e18;

    dp[buff] = 0;

    rep(i, 1, 2 * m + 1) rep(k, 1, a[i]) {
        ll val = i - m - 1;
        rrep(j, buff, -buff) {
            if (j - val >= 0) {
                maximize(dp[j + buff], dp[j - val + buff] + 1);
            }
        }
    }

    if (dp[l + buff] < 0) cout << "impossible\n"; else
    cout << dp[l + buff];

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Runtime error 3 ms 3540 KB Execution killed with signal 7
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Runtime error 3 ms 3540 KB Execution killed with signal 7
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Runtime error 3 ms 3540 KB Execution killed with signal 7
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Runtime error 3 ms 3540 KB Execution killed with signal 7
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Runtime error 3 ms 3540 KB Execution killed with signal 7
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1876 KB Output isn't correct
2 Halted 0 ms 0 KB -