Submission #745960

# Submission time Handle Problem Language Result Execution time Memory
745960 2023-05-21T10:06:43 Z vjudge1 Kitchen (BOI19_kitchen) C++17
9 / 100
1000 ms 300 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

const ll mod = 1e9 + 7;

ll f(vector<ll>& t, vector<ll>& v, int k){
    vector<pair<ll, int>> p;
    for(auto i : v){
        p.push_back({i, 0});
    }
    for(auto& i : t){
        for(int j = 0; j < p.size(); ++j){
            if(i > 0 && p[j].second < k){       //mindehol legalabb k chef
                --i;
                --p[j].first;
                ++p[j].second;
            }
        }
    }
    ll sumv = 0, sumt = 0;
    for(int j = 0; j < p.size(); ++j){
        if(p[j].second < k){
            return 1e9;
        }
        sumv += p[j].first;
    }
    for(auto& i : t){
        sumt += i;
    }
    if(sumt - sumv < 0) return 1e9;
    return sumt - sumv;
}

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> v(n), t(m);
    ll sumv = 0;
    for(auto& i : v){
        cin >> i;
    }
    for(auto& i : t){
        cin >> i;
    }
    if(m < k || *min_element(begin(v), end(v)) < k){
        cout << "Impossible" << endl;
        return 0;
    }
    ll sol = 1e9;
    for(ll i = 0; i < (1ll << m); ++i){
        vector<ll> munkas;
        for(int j = 0; j < m; ++j){
            if((1ll << j) & i){
                munkas.push_back(t[j]);
            }
        }
        sol = min(sol, f(munkas, v, k));
    }
    if(sol == 1e9){
        cout << "Impossible" << endl;
    }
    else{
        cout << sol << endl;
    }
    return 0;
}

Compilation message

kitchen.cpp: In function 'll f(std::vector<long long int>&, std::vector<long long int>&, int)':
kitchen.cpp:14:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         for(int j = 0; j < p.size(); ++j){
      |                        ~~^~~~~~~~~~
kitchen.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int j = 0; j < p.size(); ++j){
      |                    ~~^~~~~~~~~~
kitchen.cpp: In function 'int main()':
kitchen.cpp:40:8: warning: unused variable 'sumv' [-Wunused-variable]
   40 |     ll sumv = 0;
      |        ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 14 ms 212 KB Output is correct
10 Correct 11 ms 300 KB Output is correct
11 Correct 22 ms 284 KB Output is correct
12 Correct 35 ms 280 KB Output is correct
13 Incorrect 284 ms 212 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 14 ms 212 KB Output is correct
10 Correct 11 ms 300 KB Output is correct
11 Correct 22 ms 284 KB Output is correct
12 Correct 35 ms 280 KB Output is correct
13 Incorrect 284 ms 212 KB Output isn't correct
14 Halted 0 ms 0 KB -