Submission #985196

# Submission time Handle Problem Language Result Execution time Memory
985196 2024-05-17T12:21:32 Z OAleksa Kitchen (BOI19_kitchen) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N = 310;
int n, m, k, a[N], b[N];
pair<int, int> dp[N * N], ndp[N * N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n >> m >> k;
  	for (int i = 1;i <= n;i++)
  		cin >> a[i];
  	int sum = 0;
  	sort(a + 1, a + n + 1);
  	for (int i = 1;i <= n;i++)
  		sum += a[i];
  	for (int i = 1;i <= m;i++)
  		cin >> b[i];
  	sort(b + 1, b + m + 1);
  	for (int i = 1;i <= m;i++)
  		cout << b[i] << ' ';
  	cout << endl;
  	if (m < k || a[1] < k)
  		cout << "Impossible";
  	else {
  		int ans = 1e9;
  		for (int mask = 1;mask < (1 << m);mask++) {
  			int x = __builtin_popcount(mask);
  			if (x < k)
  				continue;
  			int s = 0, is = 0, all = 0;
  			for (int i = 0;i < m;i++) {
  				if (mask >> i & 1) {
  					all += b[i + 1];
  					if (s < n * k) {
  						is += 1;
  						s += min(n * k - s, min(b[i + 1], n));
  					}
  				}
  			}
  			if (is >= k && all >= sum && s == n * k)
  				ans = min(ans, all - sum);
  		}
  		if (ans >= 1e9)
  			cout << "Impossible\n";
  		else
  			cout << ans << '\n';
  	}
  }
  return 0; 
}
# 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 Incorrect 1 ms 344 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 Incorrect 0 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 -