Submission #667169

# Submission time Handle Problem Language Result Execution time Memory
667169 2022-11-30T15:58:21 Z Kahou Kitchen (BOI19_kitchen) C++14
9 / 100
5 ms 328 KB
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 305;
int n, m, k, a[N], b[N], c[N];
vector<int> vc;
void solve() {
	cin >> n >> m >> k;
	int sm = 0;
	bool flg = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sm += a[i];
		flg = flg&&(a[i] >= k);
	}
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
	}
	if (!flg) {
		cout << "Impossible" << endl;
		return;
	}
	int ans = 1e9;
	for (int mask = 0; mask < (1<<m); mask++) {
		vc.clear();
		int sm2 = 0;
		for (int i = 1; i <= m; i++) {
			if (mask>>(i-1)&1) {
				vc.push_back(b[i]);
				sm2 += b[i];
			}
		}
		if (sm2 < sm) continue;
		sort(vc.begin(), vc.end());

		int tmp = 0;
		int t = 0;
		for (int i = 0; i <= (int)vc.size()-k; i++) {
			c[i] = vc[i] - tmp;
			t += c[i];
			tmp += c[i];
			if (i >= k-1) tmp -= c[i-k+1];
		}
		if (t >= n) ans = min(ans, sm2-sm);
	}
	if (ans >= 1e9) {
		cout << "Impossible" << endl;
		return;
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
	return 0;
}

# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 5 ms 212 KB Output is correct
10 Correct 3 ms 212 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Incorrect 2 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 5 ms 212 KB Output is correct
10 Correct 3 ms 212 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Incorrect 2 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -