Submission #1026679

# Submission time Handle Problem Language Result Execution time Memory
1026679 2024-07-18T09:12:26 Z gyg Uplifting Excursion (BOI22_vault) C++17
0 / 100
203 ms 720 KB
#include <bits/stdc++.h>    
using namespace std;
#define int long long
const int OFFSET = 1e4, INF = 9e18;

int n, tar;
unordered_map<int, int> t;

array<int, 2 * OFFSET + 5> dp;
void comp() {
    fill(dp.begin(), dp.end(), -INF);
    dp[0 + OFFSET] = 0;
    for (int x = -n; x <= n; x++) {
        for (int i = 1; i <= t[x]; i++) {
            array<int, 2 * OFFSET + 5> old_dp = dp;
            for (int y = OFFSET; y >= -OFFSET; y--)
                if (-OFFSET <= y - x && y - x <= OFFSET) dp[y + OFFSET] = max(old_dp[y + OFFSET], old_dp[y - x + OFFSET] + 1);
        }
    }
}

signed main() {
    // freopen("vault.in", "r", stdin);
    cin >> n >> tar; assert(tar != 0);
    if (tar < -OFFSET || tar > OFFSET) { cout << "impossible" << '\n'; exit(0); }
    for (int i = -n; i <= n; i++) cin >> t[i];

    comp();

    cout << ((dp[tar + OFFSET] < 0) ? "impossible" : to_string(dp[tar + OFFSET])) << '\n';
    
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 203 ms 720 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 203 ms 720 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 203 ms 720 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 203 ms 720 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 203 ms 720 KB Output isn't correct
7 Halted 0 ms 0 KB -