Submission #745867

# Submission time Handle Problem Language Result Execution time Memory
745867 2023-05-21T08:53:42 Z vjudge1 Kitchen (BOI19_kitchen) C++17
9 / 100
1000 ms 296 KB
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

struct meal {
	int t, k;
	bool operator<(const  meal& m)const {
		return k < m.k;
	}
};

int check(int mask, vector<int>& ch, vector<meal>& m) {
	priority_queue<meal> q;
	int sum = 0;
	for (meal i : m) {
		q.push(i);
		sum += i.t;
	}
	for (int i = 0; i < ch.size(); i++) {
		if (((1 << i)&mask) == 0)continue;
		sum -= ch[i];
		vector<meal> out;
		for (int j = 0; j < ch[i]; j++) {
			if (q.empty())break;
			meal x = q.top();
			q.pop();
			x.k--;
			out.push_back(x);
		}
		for (meal j : out)q.push(j);
	}
	if (q.top().k > 0 || sum > 0)return INT32_MAX;
	return -sum;
}

int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, m, k;
	cin >> n >> m >> k;
	vector<meal> meals(n);
	bool b = 1;
	for (int i = 0; i < n; i++) {
		cin >> meals[i].t;
		meals[i].k = k;
		if (meals[i].t < k)b = 0;
	}
	vector<int> ch(m);
	for (int& i : ch)cin >> i;
	int ans = INT32_MAX;
	
	for (int i = 0; i < (1 << m); i++) {
		ans = min(ans, check(i, ch, meals));
	}
	if (ans == INT32_MAX || !b)cout << "Impossible\n";
	else cout << ans << endl;
}

Compilation message

kitchen.cpp: In function 'int check(int, std::vector<int>&, std::vector<meal>&)':
kitchen.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for (int i = 0; i < ch.size(); i++) {
      |                  ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 212 KB Output is correct
8 Correct 0 ms 244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 212 KB Output is correct
8 Correct 0 ms 244 KB Output is correct
9 Correct 57 ms 212 KB Output is correct
10 Correct 34 ms 212 KB Output is correct
11 Correct 114 ms 292 KB Output is correct
12 Correct 132 ms 296 KB Output is correct
13 Execution timed out 1092 ms 212 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 212 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 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 212 KB Output is correct
8 Correct 0 ms 244 KB Output is correct
9 Correct 57 ms 212 KB Output is correct
10 Correct 34 ms 212 KB Output is correct
11 Correct 114 ms 292 KB Output is correct
12 Correct 132 ms 296 KB Output is correct
13 Execution timed out 1092 ms 212 KB Time limit exceeded
14 Halted 0 ms 0 KB -