답안 #721841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721841 2023-04-11T07:45:52 Z OttincaM Uplifting Excursion (BOI22_vault) C++17
0 / 100
5000 ms 2992 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 = 4000000;
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;
    int smn = 0, smf = 0;
    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);
                smn += i - 1 - m;
            } else if(i - 1 - m < 0){
                y.push_back(i - 1 - m);
                smf += i - 1 - m;
            } else {
                z.push_back(i - 1 - m);
            }
         }
    }
    if(l > smn || l < smf){
        cout << "impossible\n"; return 0;
    }
    map <int, int> dp;
    dp[0] = (int)z.size();

    for(int t: x){
        vector <int> id;
        for(auto p: dp) id.push_back(p.first);
        // cout << id.size() << "\n";
        for(int i = id.size() - 1; i >= 0; i --){
            dp[id[i] + t] = max(dp[id[i] + t], dp[id[i]] + 1);
            // cout << id[i] + t << " " << dp[id[i] + t] << "\n";
        }

    }

    for(int t: y){
        vector <int> id;
        for(auto p: dp) id.push_back(p.first);

        for(int i = 0; i < id.size(); i ++){
            dp[id[i] + t] = max(dp[id[i] + t], dp[id[i]] + 1);
        }
    }

    if(dp.find(l) == dp.end()){
        cout << "impossible\n";
    } else {
        cout << dp[l] << "\n";
    }
    return 0;
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:61:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for(int i = 0; i < id.size(); i ++){
      |                        ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 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 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Execution timed out 5066 ms 2992 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Execution timed out 5066 ms 2992 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Execution timed out 5066 ms 2992 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Execution timed out 5066 ms 2992 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Execution timed out 5066 ms 2992 KB Time limit exceeded
7 Halted 0 ms 0 KB -