답안 #721897

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721897 2023-04-11T08:36:14 Z sunnat Uplifting Excursion (BOI22_vault) C++14
5 / 100
641 ms 2460 KB
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
using namespace std;

int main(){
    vector<int> dp[2];
    int n, m, res = -1;
    cin >> n >> m;
    vector<int>a(2*n+1);
    int q = 65000;
    for(int i = 0; i < a.size(); i ++)
        cin >> a[i];
    dp[1].resize(2*q+1, -1);
    dp[1][q] = 0;
    for(int val = -n; val <= n; val ++){
        // cout << val << endl;
        if(val == 0) continue;
        dp[0]  = dp[1];
        int v = val + n;
        for(int cnt = 1; cnt <= a[v]; cnt ++){
            for(int sum = -q; sum <= q; sum ++){
                if(dp[1][sum+q] != -1)
                    //if(-q <= sum+val*cnt && sum+val*cnt <= q)
                        dp[0][sum+val*cnt+q] = max(dp[0][sum+val*cnt+q], dp[1][sum+q] + cnt);
            }
        }
        dp[1] = dp[0];
    }
    if(-q<=m && m <= q && dp[1][m+q] != -1)
        cout << dp[1][m+q] + a[n];
    else
        cout << "impossible";
    return 0;
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:16:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i = 0; i < a.size(); i ++)
      |                    ~~^~~~~~~~~~
vault.cpp:12:15: warning: unused variable 'res' [-Wunused-variable]
   12 |     int n, m, res = -1;
      |               ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1236 KB Output is correct
2 Correct 3 ms 1236 KB Output is correct
3 Correct 2 ms 1236 KB Output is correct
4 Correct 10 ms 1236 KB Output is correct
5 Correct 4 ms 1236 KB Output is correct
6 Correct 309 ms 1312 KB Output is correct
7 Correct 111 ms 1304 KB Output is correct
8 Correct 289 ms 1304 KB Output is correct
9 Correct 617 ms 1304 KB Output is correct
10 Correct 12 ms 1328 KB Output is correct
11 Correct 13 ms 1324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1236 KB Output is correct
2 Correct 3 ms 1236 KB Output is correct
3 Correct 2 ms 1236 KB Output is correct
4 Correct 10 ms 1236 KB Output is correct
5 Correct 4 ms 1236 KB Output is correct
6 Correct 309 ms 1312 KB Output is correct
7 Correct 111 ms 1304 KB Output is correct
8 Correct 289 ms 1304 KB Output is correct
9 Correct 617 ms 1304 KB Output is correct
10 Correct 12 ms 1328 KB Output is correct
11 Correct 13 ms 1324 KB Output is correct
12 Correct 2 ms 1236 KB Output is correct
13 Correct 2 ms 1236 KB Output is correct
14 Correct 2 ms 1236 KB Output is correct
15 Correct 7 ms 1236 KB Output is correct
16 Correct 4 ms 1236 KB Output is correct
17 Correct 323 ms 1308 KB Output is correct
18 Correct 110 ms 1308 KB Output is correct
19 Correct 293 ms 1236 KB Output is correct
20 Correct 641 ms 1308 KB Output is correct
21 Correct 14 ms 1236 KB Output is correct
22 Correct 15 ms 1236 KB Output is correct
23 Correct 10 ms 1236 KB Output is correct
24 Runtime error 77 ms 2460 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Incorrect 3 ms 1236 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Incorrect 3 ms 1236 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Incorrect 3 ms 1236 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1236 KB Output is correct
2 Correct 3 ms 1236 KB Output is correct
3 Correct 2 ms 1236 KB Output is correct
4 Correct 10 ms 1236 KB Output is correct
5 Correct 4 ms 1236 KB Output is correct
6 Correct 309 ms 1312 KB Output is correct
7 Correct 111 ms 1304 KB Output is correct
8 Correct 289 ms 1304 KB Output is correct
9 Correct 617 ms 1304 KB Output is correct
10 Correct 12 ms 1328 KB Output is correct
11 Correct 13 ms 1324 KB Output is correct
12 Correct 7 ms 1236 KB Output is correct
13 Incorrect 3 ms 1236 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Incorrect 3 ms 1236 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1236 KB Output is correct
2 Correct 3 ms 1236 KB Output is correct
3 Correct 2 ms 1236 KB Output is correct
4 Correct 10 ms 1236 KB Output is correct
5 Correct 4 ms 1236 KB Output is correct
6 Correct 309 ms 1312 KB Output is correct
7 Correct 111 ms 1304 KB Output is correct
8 Correct 289 ms 1304 KB Output is correct
9 Correct 617 ms 1304 KB Output is correct
10 Correct 12 ms 1328 KB Output is correct
11 Correct 13 ms 1324 KB Output is correct
12 Correct 2 ms 1236 KB Output is correct
13 Correct 2 ms 1236 KB Output is correct
14 Correct 2 ms 1236 KB Output is correct
15 Correct 7 ms 1236 KB Output is correct
16 Correct 4 ms 1236 KB Output is correct
17 Correct 323 ms 1308 KB Output is correct
18 Correct 110 ms 1308 KB Output is correct
19 Correct 293 ms 1236 KB Output is correct
20 Correct 641 ms 1308 KB Output is correct
21 Correct 14 ms 1236 KB Output is correct
22 Correct 15 ms 1236 KB Output is correct
23 Correct 10 ms 1236 KB Output is correct
24 Runtime error 77 ms 2460 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Incorrect 3 ms 1236 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1236 KB Output is correct
2 Correct 3 ms 1236 KB Output is correct
3 Correct 2 ms 1236 KB Output is correct
4 Correct 10 ms 1236 KB Output is correct
5 Correct 4 ms 1236 KB Output is correct
6 Correct 309 ms 1312 KB Output is correct
7 Correct 111 ms 1304 KB Output is correct
8 Correct 289 ms 1304 KB Output is correct
9 Correct 617 ms 1304 KB Output is correct
10 Correct 12 ms 1328 KB Output is correct
11 Correct 13 ms 1324 KB Output is correct
12 Correct 2 ms 1236 KB Output is correct
13 Correct 2 ms 1236 KB Output is correct
14 Correct 2 ms 1236 KB Output is correct
15 Correct 7 ms 1236 KB Output is correct
16 Correct 4 ms 1236 KB Output is correct
17 Correct 323 ms 1308 KB Output is correct
18 Correct 110 ms 1308 KB Output is correct
19 Correct 293 ms 1236 KB Output is correct
20 Correct 641 ms 1308 KB Output is correct
21 Correct 14 ms 1236 KB Output is correct
22 Correct 15 ms 1236 KB Output is correct
23 Correct 10 ms 1236 KB Output is correct
24 Runtime error 77 ms 2460 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -