# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
566940 |
2022-05-23T06:40:15 Z |
shrimb |
Kitchen (BOI19_kitchen) |
C++17 |
|
1 ms |
324 KB |
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,fma")
#include"bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define endl '\n'
#define mod 1000000007
//\
#define mod 1686876991
const int maxn = 301;
int n, m, k, cntAK, cntBK, smA, smB, ans = 1e9;
int A[maxn], B[maxn];
signed main () {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m >> k;
for (int i = 0 ; i < n ; i++) {
cin >> A[i];
smA += A[i];
if (A[i] < k) cntAK++;
}
for (int i = 0 ; i < m ; i++) {
cin >> B[i];
if (B[i] >= k) cntBK++;
smB += B[i];
}
if (m < k || smB < smA || cntBK < n || cntAK) {
cout << "Impossible\n";
return 0;
}
if (m <= 15) { // subtasks 1 and 2
for (int i = 0 ; i < (1 << m) ; i++) {
smB = 0, cntBK = 0;
if (__builtin_popcount(i) < k) continue;
for (int j = 0 ; j < m ; j++) {
if (i & (1 << j)) {
smB += B[j];
if (B[j] >= k) cntBK++;
}
}
if (smB >= smA and cntBK >= n) ans = min(ans, smB - smA);
}
cout << ans << endl;
}
}
/*
impossible:
- M < K
- sum of B < sum of A
- the number of (B >= K) is < N
- theres an A which is < K
*/
Compilation message
kitchen.cpp:17:1: warning: multi-line comment [-Wcomment]
17 | //\
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
2 |
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 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |