Submission #315775

# Submission time Handle Problem Language Result Execution time Memory
315775 2020-10-24T00:39:08 Z FlashGamezzz Kitchen (BOI19_kitchen) C++17
100 / 100
88 ms 1144 KB
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>

using namespace std;

int n, m, k, sum = 0, last[90001], dp[90001] = {};

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++){
		int a; cin >> a;
		if (a < k){
			cout << "Impossible" << endl; return 0;
		}
		sum += a;
	}
	last[0] = 0;
	for (int i = 1; i <= 90000; i++){
		last[i] = -1; dp[i] = -1;
	}
	for (int i = 0; i < m; i++){
		int c; cin >> c;
		for (int j = 0; j <= 90000-c; j++){
			if (last[j] >= 0){
				dp[j] = max(dp[j], last[j]);
				dp[j+c] = max(dp[j+c], last[j]+min(n, c));
			}
		}
		swap(dp, last);
		for (int j = 0; j <= 90000; j++){
			dp[j] = -1;
		}
	}
	for (int i = sum; i <= 90000; i++){
		if (last[i] >= n*k){
			cout << i-sum; return 0;
		}
	}
	cout << "Impossible" << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1024 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 1 ms 1056 KB Output is correct
5 Correct 1 ms 1024 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 416 KB Output is correct
8 Correct 1 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1024 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 1 ms 1056 KB Output is correct
5 Correct 1 ms 1024 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 416 KB Output is correct
8 Correct 1 ms 1024 KB Output is correct
9 Correct 4 ms 1024 KB Output is correct
10 Correct 4 ms 1024 KB Output is correct
11 Correct 4 ms 1024 KB Output is correct
12 Correct 4 ms 1024 KB Output is correct
13 Correct 6 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 1024 KB Output is correct
2 Correct 55 ms 1024 KB Output is correct
3 Correct 88 ms 1088 KB Output is correct
4 Correct 82 ms 1096 KB Output is correct
5 Correct 76 ms 1144 KB Output is correct
6 Correct 52 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1036 KB Output is correct
2 Correct 10 ms 1024 KB Output is correct
3 Correct 10 ms 1024 KB Output is correct
4 Correct 10 ms 1024 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1024 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 1 ms 1056 KB Output is correct
5 Correct 1 ms 1024 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 416 KB Output is correct
8 Correct 1 ms 1024 KB Output is correct
9 Correct 4 ms 1024 KB Output is correct
10 Correct 4 ms 1024 KB Output is correct
11 Correct 4 ms 1024 KB Output is correct
12 Correct 4 ms 1024 KB Output is correct
13 Correct 6 ms 1024 KB Output is correct
14 Correct 63 ms 1024 KB Output is correct
15 Correct 55 ms 1024 KB Output is correct
16 Correct 88 ms 1088 KB Output is correct
17 Correct 82 ms 1096 KB Output is correct
18 Correct 76 ms 1144 KB Output is correct
19 Correct 52 ms 1024 KB Output is correct
20 Correct 10 ms 1036 KB Output is correct
21 Correct 10 ms 1024 KB Output is correct
22 Correct 10 ms 1024 KB Output is correct
23 Correct 10 ms 1024 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 50 ms 1024 KB Output is correct
26 Correct 61 ms 1024 KB Output is correct
27 Correct 40 ms 1024 KB Output is correct
28 Correct 66 ms 1024 KB Output is correct
29 Correct 66 ms 1024 KB Output is correct
30 Correct 84 ms 1088 KB Output is correct