Submission #745869

# Submission time Handle Problem Language Result Execution time Memory
745869 2023-05-21T08:58:39 Z vjudge1 Kitchen (BOI19_kitchen) C++17
31 / 100
3 ms 312 KB
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

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

int sum1, sum2;

int check(int mask, vector<int>& ch, vector<meal>& m) {
	priority_queue<meal> q;
	int x = sum1, y = sum2;
	
	for (int i = 0; i < ch.size(); i++) {
		if (((1 << i)&mask) == 0)continue;
		x -= ch[i];
		y -= min((int)m.size(), ch[i]);
	}
	if (y > 0 || x > 0)return INT32_MAX;
	return -x;
}

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;
		sum1 += meals[i].t;
		sum2 += k;
	}
	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 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 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 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 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 2 ms 312 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
# 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 1 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 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 2 ms 312 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Incorrect 0 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -