Submission #745961

# Submission time Handle Problem Language Result Execution time Memory
745961 2023-05-21T10:06:53 Z vjudge1 Kitchen (BOI19_kitchen) C++17
9 / 100
13 ms 468 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 301;

int dp[MAXN][MAXN];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n, m, k; cin >> n >> m >> k;
	vector<int> a(n+1), b(n+1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int j = 1; j <= m; j++) {
		cin >> b[j];
	}
	
	int ans = INT_MAX;
	for (int bits = 0; bits < (1 << m); bits++) {
		int x = bits<<1;
		priority_queue<int> pq;
		for (int i = 1; i <= n; i++) {
			pq.push(a[i]);
		}
		multiset<int> chefs;
		for (int i = 1; i <= m; i++) {
			if ((x>>i)&1) {
				chefs.insert(b[i]);
			}
		}

		bool possible = true;
		while (!pq.empty() && !chefs.empty()) {
			bool good = false;
			int left = pq.top();
			pq.pop();
			if (chefs.size() < k || left < k) {
				possible = false;
				break;
			}
			while (left && !chefs.empty()) {
				vector<int> used;
				for (int u : chefs) {
					if (left) {
						left--;
						used.push_back(u);
					}
				}
				for (int u : used) {
					chefs.erase(chefs.find(u));
					if (u != 1) chefs.insert(u-1);
				}
			}
			if (left) {
				possible = false;
				break;
			}
		}
		if (possible && pq.empty()) {
			int res = 0;
			for (int u : chefs) res += u;
			ans = min(ans, res);
		}

	}
	if (ans == INT_MAX)
		cout << "Impossible\n";
	else
		cout << ans << "\n";
	return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:38:21: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |    if (chefs.size() < k || left < k) {
      |        ~~~~~~~~~~~~~^~~
kitchen.cpp:35:9: warning: unused variable 'good' [-Wunused-variable]
   35 |    bool good = false;
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 224 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 224 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Runtime error 1 ms 468 KB Execution killed with signal 6
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 224 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Runtime error 1 ms 468 KB Execution killed with signal 6
10 Halted 0 ms 0 KB -