답안 #370318

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
370318 2021-02-23T18:32:45 Z wind_reaper Kitchen (BOI19_kitchen) C++17
100 / 100
53 ms 748 KB
#include <bits/stdc++.h>

using namespace std;

const int MXN = 301;
const int INF = 1e9;

int32_t main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	
	int n, m, k;
	cin >> n >> m >> k;

	vector<int> a(n), b(m);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < m; i++)
		cin >> b[i];

	if(*min_element(a.begin(), a.end()) < k){
		cout << "Impossible\n";
		return 0;
	}

	vector<int> dp(MXN*MXN, -INF);
	dp[0] = 0;

	for(int i = 0; i < m; i++){
		for(int W = MXN*MXN - 1; W >= b[i]; --W)
			dp[W] = max(dp[W], dp[W-b[i]] + min(b[i], n));
	}

	int sum = accumulate(a.begin(), a.end(), 0);
	int ans = INF;
	for(int W = sum; W < MXN*MXN; W++)
		if(dp[W] >= n*k)
			ans = min(ans, W - sum);

	cout << (ans != INF ? to_string(ans) : "Impossible") << '\n';
	return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 1 ms 620 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 392 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 1 ms 620 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 392 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 5 ms 620 KB Output is correct
10 Correct 3 ms 620 KB Output is correct
11 Correct 3 ms 620 KB Output is correct
12 Correct 3 ms 620 KB Output is correct
13 Correct 3 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 748 KB Output is correct
2 Correct 36 ms 648 KB Output is correct
3 Correct 53 ms 748 KB Output is correct
4 Correct 50 ms 748 KB Output is correct
5 Correct 47 ms 748 KB Output is correct
6 Correct 33 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 748 KB Output is correct
2 Correct 7 ms 620 KB Output is correct
3 Correct 7 ms 620 KB Output is correct
4 Correct 7 ms 620 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 1 ms 620 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 392 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 5 ms 620 KB Output is correct
10 Correct 3 ms 620 KB Output is correct
11 Correct 3 ms 620 KB Output is correct
12 Correct 3 ms 620 KB Output is correct
13 Correct 3 ms 620 KB Output is correct
14 Correct 42 ms 748 KB Output is correct
15 Correct 36 ms 648 KB Output is correct
16 Correct 53 ms 748 KB Output is correct
17 Correct 50 ms 748 KB Output is correct
18 Correct 47 ms 748 KB Output is correct
19 Correct 33 ms 620 KB Output is correct
20 Correct 7 ms 748 KB Output is correct
21 Correct 7 ms 620 KB Output is correct
22 Correct 7 ms 620 KB Output is correct
23 Correct 7 ms 620 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 33 ms 620 KB Output is correct
26 Correct 38 ms 620 KB Output is correct
27 Correct 26 ms 620 KB Output is correct
28 Correct 38 ms 620 KB Output is correct
29 Correct 39 ms 620 KB Output is correct
30 Correct 49 ms 748 KB Output is correct