Submission #958375

# Submission time Handle Problem Language Result Execution time Memory
958375 2024-04-05T15:49:03 Z Nomio Kitchen (BOI19_kitchen) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m, k;
	cin >> n >> m >> k;
	int a[n], b[m];
	bool w = 1;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] < k) {
			w = 0;
		}
	}
	for(int i = 0; i < m; i++) {
		cin >> b[i];
	}
	if(!w || m < k) {
		cout << "Impossible" << "\n";
		return 0;
	}
	bool dp[301] {};
	dp[0] = 1;
	for(int i = 0; i < m; i++) {
		for(int j = 0; j <= 300; j++) {
			if(dp[j] && j + b[i] <= 300) {
				dp[j + b[i]] = 1;
			}
		}
	}
	vector<int> v;
	for(int i = 1; i <= 300; i++) {
		if(dp[i]) v.push_back(i);
	} 
	int S = 0;
	for(int i = 0; i < n; i++) {
		if(v.back() < a[i]) {
			cout << "Impossible" << "\n";
			return 0;
		}
		int x = upper_bound(v.begin(), v.end(), a[i]) - v.begin();
		if(v[x - 1] != a[i]) {
			S += (v[x] - a[i]);
		}
	}
	cout << S << "\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -