Submission #721891

# Submission time Handle Problem Language Result Execution time Memory
721891 2023-04-11T08:29:28 Z sunnat Uplifting Excursion (BOI22_vault) C++14
0 / 100
6 ms 2516 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(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;
      |               ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 2 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Runtime error 6 ms 2516 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 2 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Runtime error 6 ms 2516 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1236 KB Output is correct
2 Runtime error 4 ms 2388 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1236 KB Output is correct
2 Runtime error 4 ms 2388 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1236 KB Output is correct
2 Runtime error 4 ms 2388 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 2 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Runtime error 6 ms 2516 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1236 KB Output is correct
2 Runtime error 4 ms 2388 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 2 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Runtime error 6 ms 2516 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1236 KB Output is correct
2 Runtime error 4 ms 2388 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 2 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Runtime error 6 ms 2516 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -