Submission #1004572

# Submission time Handle Problem Language Result Execution time Memory
1004572 2024-06-21T09:56:15 Z HasanV11010238 Kitchen (BOI19_kitchen) C++17
9 / 100
11 ms 432 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000
int main(){
    ll n, m, k, su = 0, bsu = 0;
    cin>>n>>m>>k;
    bool ca = 0;
    if (m < k){
        ca = 1;
    }
    vector<ll> a(n + 1), b(m + 1);
    for (int i = 0;  i< n; i++){
        cin>>a[i];
        su += a[i];
        if (a[i] < k){
            ca = 1;
        }
    }
    for (int i = 0; i < m; i++){
        cin>>b[i];
        bsu += b[i];
    }
    if (ca || bsu < su){
        cout<<"Impossible";
        return 0;
    }
    ll ans = INF;
    int ti = (1<<m);
    for (int i = 0; i < ti; i++){
        ll msu = 0;
        vector<int> ti(n, k), mval;
        for (int j = 0; j < m; j++){
            int val = i & (1<<j);
            if (val != 0){
                msu += b[j];
                mval.push_back(b[j]);
            }
        }
        int le = n;
        for (int j = 0; j < n; j++){
            for (int k = 0; k < mval.size(); k++){
                if (mval[k] != 0 && ti[j] != 0){
                    mval[k]--;
                    ti[j]--;
                    if (ti[j] == 0){
                        le--;
                    }
                }
            }
        }
        if (le == 0){
            if (msu >= su){
                ans = min(ans, msu - su);
            }
        }
    }
    cout<<ans;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:42:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             for (int k = 0; k < mval.size(); k++){
      |                             ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 8 ms 344 KB Output is correct
10 Correct 10 ms 432 KB Output is correct
11 Incorrect 11 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 8 ms 344 KB Output is correct
10 Correct 10 ms 432 KB Output is correct
11 Incorrect 11 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -