Submission #385516

# Submission time Handle Problem Language Result Execution time Memory
385516 2021-04-04T14:15:54 Z rqi Kitchen (BOI19_kitchen) C++14
100 / 100
37 ms 748 KB
#include <bits/stdc++.h>
using namespace std;

void ckmin(int& a, int b){
	a = min(a, b);
}

void ckmax(int& a, int b){
	a = max(a, b);
}

const int MOD = 1e9+7;

const int mx = 305;
int N, M, K;

int Asum = 0;
int A[mx];
int B[mx];
int Bp[mx];

int dp[305*305];

int main(){
	cin >> N >> M >> K;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		Asum+=A[i];
	}
	for(int i = 0; i < M; i++){
		cin >> B[i];
	}

	for(int i = 0; i < N; i++){
		if(A[i] < K){
			cout << "Impossible" << "\n";
			exit(0);
		}
	}

	for(int i = 0; i < M; i++){
		Bp[i] = min(B[i], N);
	}

	for(int i = 1; i < 305*305; i++){
		dp[i] = -MOD;
	}

	for(int i = 0; i < M; i++){
		for(int j = 305*305-1; j >= B[i]; j--){
			ckmax(dp[j], dp[j-B[i]]+Bp[i]);
		}

		// for(int j = 0; j <= 12; j++){
		// 	cout << dp[j] << " ";
		// }
		// cout << "\n";
	}


	for(int i = Asum; i < 305*305; i++){
		if(dp[i] >= N*K){
			cout << i-Asum << "\n";
			exit(0);
		}
	}
	cout << "Impossible" << "\n";
	

}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 1 ms 748 KB Output is correct
3 Correct 1 ms 748 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 1 ms 748 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 1 ms 748 KB Output is correct
3 Correct 1 ms 748 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 1 ms 748 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 748 KB Output is correct
9 Correct 3 ms 748 KB Output is correct
10 Correct 3 ms 748 KB Output is correct
11 Correct 3 ms 748 KB Output is correct
12 Correct 3 ms 748 KB Output is correct
13 Correct 3 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 748 KB Output is correct
2 Correct 22 ms 748 KB Output is correct
3 Correct 37 ms 748 KB Output is correct
4 Correct 30 ms 748 KB Output is correct
5 Correct 27 ms 748 KB Output is correct
6 Correct 20 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 748 KB Output is correct
2 Correct 5 ms 748 KB Output is correct
3 Correct 5 ms 748 KB Output is correct
4 Correct 5 ms 748 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 1 ms 748 KB Output is correct
3 Correct 1 ms 748 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 1 ms 748 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 748 KB Output is correct
9 Correct 3 ms 748 KB Output is correct
10 Correct 3 ms 748 KB Output is correct
11 Correct 3 ms 748 KB Output is correct
12 Correct 3 ms 748 KB Output is correct
13 Correct 3 ms 748 KB Output is correct
14 Correct 25 ms 748 KB Output is correct
15 Correct 22 ms 748 KB Output is correct
16 Correct 37 ms 748 KB Output is correct
17 Correct 30 ms 748 KB Output is correct
18 Correct 27 ms 748 KB Output is correct
19 Correct 20 ms 748 KB Output is correct
20 Correct 5 ms 748 KB Output is correct
21 Correct 5 ms 748 KB Output is correct
22 Correct 5 ms 748 KB Output is correct
23 Correct 5 ms 748 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 20 ms 748 KB Output is correct
26 Correct 23 ms 748 KB Output is correct
27 Correct 16 ms 748 KB Output is correct
28 Correct 23 ms 748 KB Output is correct
29 Correct 25 ms 744 KB Output is correct
30 Correct 28 ms 748 KB Output is correct