Submission #721814

# Submission time Handle Problem Language Result Execution time Memory
721814 2023-04-11T07:34:16 Z OttincaM Uplifting Excursion (BOI22_vault) C++17
0 / 100
631 ms 308 KB
#include <iostream>
#include <vector>
#include "stdio.h"
#include <map>

using namespace std;
// #define int long long

long long const LLINF = 2e9 + 1;
int const N = 2000000;
int const ZER = 1000000;

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    #ifdef WTF
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt", "w", stderr);
    #endif


    int m, l; cin >> m >> l;
    vector <int> a(2 * m + 2), x, y, z;
    for(int i = 1; i <= 2 * m + 1; i ++){
         cin >> a[i];
         int K = a[i];
         while(K --){
            if(i - 1 - m > 0){
                x.push_back(i - 1 - m);
            } else if(i - 1 - m < 0){
                y.push_back(i - 1 - m);
            } else {
                z.push_back(i - 1 - m);
            }
         }
    }

    map <int, int> dp;
    dp[ZER] = (int)z.size();

    for(int t: x){
        for(int i = N - 1; i >= 0; i--){
            if(i - t >= 0 && dp.find(i - t) != dp.end()){
                dp[i] = max(dp[i], dp[i - t] + 1);
            }
        }

    }

    for(int t: y){
        for(int i = 0; i < N; i ++){
            if(i - t < N && dp.find(i - t) != dp.end()){
                dp[i] = max(dp[i], dp[i - t] + 1);
            }
        }
    }

    int ans = -LLINF;
    l += ZER;
    if(l >= 0 && l < N) ans = dp[l];
    if(ans == -LLINF){
        cout << "impossible\n";
    } else {
        cout << ans << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 131 ms 212 KB Output is correct
2 Incorrect 53 ms 296 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 131 ms 212 KB Output is correct
2 Incorrect 53 ms 296 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 631 ms 308 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 631 ms 308 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 631 ms 308 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 131 ms 212 KB Output is correct
2 Incorrect 53 ms 296 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 631 ms 308 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 131 ms 212 KB Output is correct
2 Incorrect 53 ms 296 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 631 ms 308 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 131 ms 212 KB Output is correct
2 Incorrect 53 ms 296 KB Output isn't correct
3 Halted 0 ms 0 KB -