Submission #862323

# Submission time Handle Problem Language Result Execution time Memory
862323 2023-10-18T04:00:31 Z maks007 Kitchen (BOI19_kitchen) C++14
31 / 100
7 ms 600 KB
// Bismi Allah
#include "bits/stdc++.h"

using namespace std;

#define int long long

signed main () {
	int n, m, k;
	cin >> n >> m >> k;
	int meal[n], chef[m], mealCopy[n];
	for(int i = 0; i < n; i ++) cin >> meal[i];
	for(int i = 0; i < m; i ++) cin >> chef[i];
	if(*min_element(meal, meal + n) < k) {
		cout << "Impossible";
		return 0;
	}
	if(m < k) {
		cout << "Impossible";
		return 0;
	}
	int ans = 1e9;
	for(int mask = 0; mask < (1 << m); mask ++) {
		if(__builtin_popcount(mask) < k) continue;
		vector <int> cook;
		for(int i = 0; i < m; i ++) {
			if(mask & (1 << i)) {
				cook.push_back(chef[i]);
			}
		}
		if(accumulate(cook.begin(), cook.end(), 0LL) < accumulate(meal, meal + n, 0LL)) continue;
		int cnt = 0, other = 0;
		for(int i = 0; i < cook.size(); i ++) {
			if(cook[i] >= n) cnt ++;
			else {
				other += cook[i];
			}
		}
		cnt += (other / n);
		if(cnt >= k)
			ans = min(ans, accumulate(cook.begin(), cook.end(), 0LL) - accumulate(meal, meal + n, 0LL));
	}
	if(ans == 1e9) cout << "Impossible";
	else
	cout << ans;
	return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:33:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for(int i = 0; i < cook.size(); i ++) {
      |                  ~~^~~~~~~~~~~~~
kitchen.cpp:11:24: warning: unused variable 'mealCopy' [-Wunused-variable]
   11 |  int meal[n], chef[m], mealCopy[n];
      |                        ^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 7 ms 348 KB Output is correct
# 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 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 7 ms 348 KB Output is correct
14 Incorrect 1 ms 344 KB Output isn't correct
15 Halted 0 ms 0 KB -