답안 #572990

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572990 2022-06-05T15:23:53 Z MohamedFaresNebili Uplifting Excursion (BOI22_vault) C++14
0 / 100
17 ms 24764 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

        using namespace std;
        using namespace __gnu_pbds;

        using ll = long long;
        using ii = pair<int, int>;
        using vi = vector<int>;

        #define pb push_back
        #define pp pop_back
        #define ff first
        #define ss second
        #define lb lower_bound

        typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

        const int oo = 1e9 + 7;

        int N, M, A[1000];
        map<int, int> DP[101][2500];
        int solve(int i, int curr, int state) {
            if(i == 2 * N + 1) {
                if(state == M) return curr;
                return -oo;
            }
            if(DP[i][state].count(curr))
                return DP[i][state][curr];
            int best = -oo;
            for(int l = 0; l <= A[i]; l++)
                best = max(best,
                    solve(i + 1, curr + l, state + l * (i - N)));
            return DP[i][state][curr] = best;
        }

        int32_t main() {
            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            cin >> N >> M;
            for(int l = 0; l <= 2 * N; l++) cin >> A[l];
            int ans = solve(0, 0, 0);
            if(ans == -oo) cout << "impossible\n";
            else cout << ans << "\n";
        }


























# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12116 KB Output is correct
2 Correct 6 ms 12064 KB Output is correct
3 Correct 6 ms 12140 KB Output is correct
4 Correct 10 ms 13012 KB Output is correct
5 Correct 6 ms 12116 KB Output is correct
6 Runtime error 17 ms 24764 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12116 KB Output is correct
2 Correct 6 ms 12064 KB Output is correct
3 Correct 6 ms 12140 KB Output is correct
4 Correct 10 ms 13012 KB Output is correct
5 Correct 6 ms 12116 KB Output is correct
6 Runtime error 17 ms 24764 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 13012 KB Output is correct
2 Incorrect 5 ms 12116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 13012 KB Output is correct
2 Incorrect 5 ms 12116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 13012 KB Output is correct
2 Incorrect 5 ms 12116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12116 KB Output is correct
2 Correct 6 ms 12064 KB Output is correct
3 Correct 6 ms 12140 KB Output is correct
4 Correct 10 ms 13012 KB Output is correct
5 Correct 6 ms 12116 KB Output is correct
6 Runtime error 17 ms 24764 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 13012 KB Output is correct
2 Incorrect 5 ms 12116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12116 KB Output is correct
2 Correct 6 ms 12064 KB Output is correct
3 Correct 6 ms 12140 KB Output is correct
4 Correct 10 ms 13012 KB Output is correct
5 Correct 6 ms 12116 KB Output is correct
6 Runtime error 17 ms 24764 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 13012 KB Output is correct
2 Incorrect 5 ms 12116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12116 KB Output is correct
2 Correct 6 ms 12064 KB Output is correct
3 Correct 6 ms 12140 KB Output is correct
4 Correct 10 ms 13012 KB Output is correct
5 Correct 6 ms 12116 KB Output is correct
6 Runtime error 17 ms 24764 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -