Submission #721851

# Submission time Handle Problem Language Result Execution time Memory
721851 2023-04-11T07:54:27 Z kas_s Uplifting Excursion (BOI22_vault) C++17
0 / 100
5000 ms 524288 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

int main () {
    ios::sync_with_stdio(0); cin.tie(0);
    int M; long long L;
    cin >> M >> L;
    map<long long, int> sums;
    sums[0] = 0;
    vector<int> a;
    for (int i = -M, x; i <= M; i++) {
        cin >> x;
        for (int j = 0; j < x; j++) {
            a.push_back(i);
        }
    }
    int N = (int)a.size();
    for (int i = 0; i < N; i++) {
        map<int, int> curr;
        for (auto &[k, v]: sums) {
            curr[a[i] + k] = max(curr[a[i] + k], v + 1);
        }
        for (auto &[k, v]: curr) {
            sums[k] = max(sums[k], v);
        }
    }
    if (sums.count(L)) {
        cout << sums[L] << '\n';
    } else {
        cout << "impossible\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Execution timed out 5057 ms 3976 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Execution timed out 5057 ms 3976 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 503 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 503 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 503 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Execution timed out 5057 ms 3976 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 503 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Execution timed out 5057 ms 3976 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 503 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Execution timed out 5057 ms 3976 KB Time limit exceeded
6 Halted 0 ms 0 KB -