Submission #874272

# Submission time Handle Problem Language Result Execution time Memory
874272 2023-11-16T15:12:06 Z vjudge1 Kitchen (BOI19_kitchen) C++11
100 / 100
28 ms 856 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void ex() {
	cout << "Impossible";
	exit(0);
}
int main() {

	int n, m, k;
	cin >> n >> m >> k;


	vector<int> dp (300 * 300 + 1, -1);
	vector<int> values(n), work_hours(m);
	dp[0] = 0;
	int sum = 0;
	for(int &i : values) {cin >> i; sum+=i;}
	for(int &i : work_hours) cin >> i;
	if(m < k) ex();

	for(int i : values) if(i < k) ex();

	for(int j = 0; j < m; j++) {

		for(int i = 300*300; i >= 1; i--) {
			if(i >= work_hours[j] && dp[i-work_hours[j]] != -1) {
				dp[i] = max(dp[i-work_hours[j]] + min(n, work_hours[j]), dp[i]);
			}
		}	
	}

	int ans = INT_MAX;
	for(int i = sum; i<=300*m; i++) {

		if(dp[i] >= n*k) ans = min(ans, i-sum);
	}

	if(ans == INT_MAX) ex();

	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 2 ms 856 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 604 KB Output is correct
2 Correct 16 ms 604 KB Output is correct
3 Correct 28 ms 852 KB Output is correct
4 Correct 26 ms 604 KB Output is correct
5 Correct 25 ms 604 KB Output is correct
6 Correct 15 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 4 ms 800 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 0 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 2 ms 856 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 22 ms 604 KB Output is correct
15 Correct 16 ms 604 KB Output is correct
16 Correct 28 ms 852 KB Output is correct
17 Correct 26 ms 604 KB Output is correct
18 Correct 25 ms 604 KB Output is correct
19 Correct 15 ms 604 KB Output is correct
20 Correct 3 ms 604 KB Output is correct
21 Correct 3 ms 604 KB Output is correct
22 Correct 4 ms 800 KB Output is correct
23 Correct 3 ms 604 KB Output is correct
24 Correct 0 ms 856 KB Output is correct
25 Correct 13 ms 604 KB Output is correct
26 Correct 18 ms 796 KB Output is correct
27 Correct 11 ms 600 KB Output is correct
28 Correct 19 ms 604 KB Output is correct
29 Correct 21 ms 604 KB Output is correct
30 Correct 26 ms 604 KB Output is correct