Submission #798722

# Submission time Handle Problem Language Result Execution time Memory
798722 2023-07-31T01:48:29 Z vjudge1 Kitchen (BOI19_kitchen) C++17
100 / 100
190 ms 116940 KB
#include <bits/stdc++.h>
using namespace std;

int N, M, K;
int totA;
int A[310], B[310];
int dp[310][310*310];

int f(int m, int t) {
	if (m==0) {
		if (t==0) return 0;
		else return -1e9;
	}
	int& res = dp[m][t];
	if (res != -1) return res;
	res = max(f(m-1,t), f(m-1,t-B[m])+min(N,B[m]));
//	cout << m << " " << t << " " << res << endl;
	return res;
}


int main() {
	cin >> N >> M >> K;
	for(int i=1; i<=N; i++) {
		cin >> A[i];
		totA += A[i];
		if (A[i] < K) {
			cout << "Impossible" << endl;
			return 0;
		}
	}
	for(int i=1; i<=M; i++) {
		cin >> B[i];
	}
	memset(dp, -1, sizeof(dp));
	for(int i=totA; i<=300*300; i++) {
//		cout << i << " " << f(N,i) << endl;
		if (f(M, i) >= N*K) {
			cout << i-totA << endl;
			return 0;
		}
	}
	cout << "Impossible" << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 37 ms 116812 KB Output is correct
2 Correct 37 ms 116872 KB Output is correct
3 Correct 37 ms 116844 KB Output is correct
4 Correct 38 ms 116880 KB Output is correct
5 Correct 40 ms 116856 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 39 ms 116784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 116812 KB Output is correct
2 Correct 37 ms 116872 KB Output is correct
3 Correct 37 ms 116844 KB Output is correct
4 Correct 38 ms 116880 KB Output is correct
5 Correct 40 ms 116856 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 39 ms 116784 KB Output is correct
9 Correct 37 ms 116824 KB Output is correct
10 Correct 37 ms 116796 KB Output is correct
11 Correct 45 ms 116796 KB Output is correct
12 Correct 38 ms 116764 KB Output is correct
13 Correct 40 ms 116940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 116860 KB Output is correct
2 Correct 71 ms 116824 KB Output is correct
3 Correct 90 ms 116840 KB Output is correct
4 Correct 149 ms 116884 KB Output is correct
5 Correct 190 ms 116908 KB Output is correct
6 Correct 51 ms 116796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 116864 KB Output is correct
2 Correct 39 ms 116812 KB Output is correct
3 Correct 39 ms 116848 KB Output is correct
4 Correct 38 ms 116808 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 116812 KB Output is correct
2 Correct 37 ms 116872 KB Output is correct
3 Correct 37 ms 116844 KB Output is correct
4 Correct 38 ms 116880 KB Output is correct
5 Correct 40 ms 116856 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 39 ms 116784 KB Output is correct
9 Correct 37 ms 116824 KB Output is correct
10 Correct 37 ms 116796 KB Output is correct
11 Correct 45 ms 116796 KB Output is correct
12 Correct 38 ms 116764 KB Output is correct
13 Correct 40 ms 116940 KB Output is correct
14 Correct 68 ms 116860 KB Output is correct
15 Correct 71 ms 116824 KB Output is correct
16 Correct 90 ms 116840 KB Output is correct
17 Correct 149 ms 116884 KB Output is correct
18 Correct 190 ms 116908 KB Output is correct
19 Correct 51 ms 116796 KB Output is correct
20 Correct 39 ms 116864 KB Output is correct
21 Correct 39 ms 116812 KB Output is correct
22 Correct 39 ms 116848 KB Output is correct
23 Correct 38 ms 116808 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 123 ms 116892 KB Output is correct
26 Correct 188 ms 116808 KB Output is correct
27 Correct 57 ms 116868 KB Output is correct
28 Correct 93 ms 116812 KB Output is correct
29 Correct 120 ms 116828 KB Output is correct
30 Correct 165 ms 116832 KB Output is correct