Submission #938757

# Submission time Handle Problem Language Result Execution time Memory
938757 2024-03-05T13:50:43 Z Alebn Kitchen (BOI19_kitchen) C++14
9 / 100
70 ms 600 KB
#include <bits/stdc++.h>
#define int long long
#define M 16

using namespace std;

int n, m, k, A = 0, B = 0, res = LLONG_MAX;
bool flag = false;
vector<int> a, b;

signed main() {
    cin >> n >> m >> k;
    a = vector<int>(n), b = vector<int>(m);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        A += a[i];
        if(a[i] < k) flag = true;
    }
    for(int i = 0; i < m; i++) {
        cin >> b[i];
        B += b[i];
    }
    // try every subset
    vector<int> diff;
    bitset<M> bin;
    int temp, sum;
    bool check;
    for(int i = 0; i < (1 << m); i++) {
        //cout << i << "\n";
        bin = bitset<M>(i), diff = vector<int>(n, k), sum = 0, check = true;
        for(int j = 0; j < M; j++) {
            if(bin[j]) {
                //cout << b[j] << "e ";
                sum += b[j];
                temp = b[j];
                for(int k = 0; k < n && temp; k++) {
                    if(diff[k]) {
                        diff[k]--;
                        temp--;
                    }
                }
                //for(auto i : diff) cout << i << " ";
                //cout << "\n";
            }
        }
       // cout << "\n";
        for(int j = 0; j < n; j++) {
            if(diff[j]) {
                check = false;
                break;
            }
        }
        if(check && sum >= A) res = min(res, sum - A);
    }
    if(flag || res == LLONG_MAX) cout << "Impossible\n";
    else cout << res << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 8 ms 436 KB Output is correct
13 Incorrect 70 ms 348 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 8 ms 436 KB Output is correct
13 Incorrect 70 ms 348 KB Output isn't correct
14 Halted 0 ms 0 KB -