답안 #745979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745979 2023-05-21T10:19:09 Z vjudge1 Kitchen (BOI19_kitchen) C++17
9 / 100
1000 ms 332 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 && p[j].first > 0){       //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;
      |        ^~~~
# 결과 실행 시간 메모리 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 280 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 280 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 16 ms 212 KB Output is correct
10 Correct 12 ms 212 KB Output is correct
11 Correct 24 ms 296 KB Output is correct
12 Correct 40 ms 332 KB Output is correct
13 Incorrect 307 ms 304 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 280 KB Time limit exceeded
2 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 280 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 16 ms 212 KB Output is correct
10 Correct 12 ms 212 KB Output is correct
11 Correct 24 ms 296 KB Output is correct
12 Correct 40 ms 332 KB Output is correct
13 Incorrect 307 ms 304 KB Output isn't correct
14 Halted 0 ms 0 KB -