Submission #707718

# Submission time Handle Problem Language Result Execution time Memory
707718 2023-03-09T19:48:23 Z Johann Uplifting Excursion (BOI22_vault) C++14
0 / 100
708 ms 20472 KB
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;
typedef vector<ll> vi;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

const int MAXSIZE = 1000000;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll M, L;
    cin >> M >> L;
    vi A(2 * M + 1);
    for (int i = 0; i < sz(A); ++i)
        cin >> A[i];

    vi dp(MAXSIZE, -1);
    ll center = MAXSIZE / 2;
    dp[center] = A[M];
    for (int foo = 0; foo < 2; ++foo)
    {
        reverse(all(A)), reverse(all(dp));
        for (ll m = 1; m <= M; ++m)
        {
            ll maxNum = A[m + M];
            for (ll r = 0; r < m; ++r)
            {
                priority_queue<pii, vpii> q;
                for (int i = 0; m * i + r < sz(dp); ++i)
                {
                    int idx = m * i + r;
                    while (!q.empty() && q.top().second < idx - maxNum * m)
                        q.pop();
                    if (dp[idx] != -1)
                        q.push({dp[idx] - i, idx});
                    if (!q.empty())
                        dp[idx] = i + q.top().first;
                }
            }
        }
    }

    ll ans = dp[center + L];
    if (ans == -1)
        cout << "impossible\n";
    else
        cout << ans << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 15 ms 8148 KB Output is correct
2 Correct 22 ms 8148 KB Output is correct
3 Correct 10 ms 8148 KB Output is correct
4 Correct 67 ms 8148 KB Output is correct
5 Runtime error 602 ms 16372 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 8148 KB Output is correct
2 Correct 22 ms 8148 KB Output is correct
3 Correct 10 ms 8148 KB Output is correct
4 Correct 67 ms 8148 KB Output is correct
5 Runtime error 602 ms 16372 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 8152 KB Output is correct
2 Runtime error 708 ms 20472 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 8152 KB Output is correct
2 Runtime error 708 ms 20472 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 8152 KB Output is correct
2 Runtime error 708 ms 20472 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 8148 KB Output is correct
2 Correct 22 ms 8148 KB Output is correct
3 Correct 10 ms 8148 KB Output is correct
4 Correct 67 ms 8148 KB Output is correct
5 Runtime error 602 ms 16372 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 8152 KB Output is correct
2 Runtime error 708 ms 20472 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 8148 KB Output is correct
2 Correct 22 ms 8148 KB Output is correct
3 Correct 10 ms 8148 KB Output is correct
4 Correct 67 ms 8148 KB Output is correct
5 Runtime error 602 ms 16372 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 8152 KB Output is correct
2 Runtime error 708 ms 20472 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 8148 KB Output is correct
2 Correct 22 ms 8148 KB Output is correct
3 Correct 10 ms 8148 KB Output is correct
4 Correct 67 ms 8148 KB Output is correct
5 Runtime error 602 ms 16372 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -