답안 #729074

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
729074 2023-04-23T13:09:06 Z WonderfulWhale Kitchen (BOI19_kitchen) C++17
100 / 100
34 ms 1032 KB
#include<bits/stdc++.h>
using namespace std;

#define int int64_t
#define pb push_back
#define st first
#define nd second
#define pii pair<int, int>
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

int dp[90009];

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	for(int i=0;i<=300*300;i++) dp[i] = -1e18;
	dp[0] = 0;

	int n, m, k;
	cin >> n >> m >> k;
	int sum = 0;
	for(int i=0;i<n;i++) {
		int x;
		cin >> x;
		if(x<k) {
			cout << "Impossible\n";
			return 0;
		}
		sum+=x;
	}
	for(int i=0;i<m;i++) {
		int x;
		cin >> x;
		for(int j=300*300;j>=0;j--) {
			if(j+x<=300*300) {
				dp[j+x] = max(dp[j+x], dp[j]+min(n, x));
			}
		}
	}
	for(int i=sum;i<=300*300;i++) {
		if(dp[i]>=n*k) {
			cout << i-sum << "\n";
			return 0;
		}
	}
	cout << "Impossible\n";
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 1032 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 1028 KB Output is correct
8 Correct 2 ms 1032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 1032 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 1028 KB Output is correct
8 Correct 2 ms 1032 KB Output is correct
9 Correct 2 ms 980 KB Output is correct
10 Correct 2 ms 980 KB Output is correct
11 Correct 2 ms 1024 KB Output is correct
12 Correct 2 ms 980 KB Output is correct
13 Correct 2 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 980 KB Output is correct
2 Correct 22 ms 1032 KB Output is correct
3 Correct 34 ms 980 KB Output is correct
4 Correct 29 ms 980 KB Output is correct
5 Correct 28 ms 980 KB Output is correct
6 Correct 20 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1028 KB Output is correct
2 Correct 4 ms 980 KB Output is correct
3 Correct 5 ms 1032 KB Output is correct
4 Correct 5 ms 988 KB Output is correct
5 Correct 1 ms 1028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 1032 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 1028 KB Output is correct
8 Correct 2 ms 1032 KB Output is correct
9 Correct 2 ms 980 KB Output is correct
10 Correct 2 ms 980 KB Output is correct
11 Correct 2 ms 1024 KB Output is correct
12 Correct 2 ms 980 KB Output is correct
13 Correct 2 ms 980 KB Output is correct
14 Correct 23 ms 980 KB Output is correct
15 Correct 22 ms 1032 KB Output is correct
16 Correct 34 ms 980 KB Output is correct
17 Correct 29 ms 980 KB Output is correct
18 Correct 28 ms 980 KB Output is correct
19 Correct 20 ms 980 KB Output is correct
20 Correct 4 ms 1028 KB Output is correct
21 Correct 4 ms 980 KB Output is correct
22 Correct 5 ms 1032 KB Output is correct
23 Correct 5 ms 988 KB Output is correct
24 Correct 1 ms 1028 KB Output is correct
25 Correct 18 ms 980 KB Output is correct
26 Correct 28 ms 1008 KB Output is correct
27 Correct 19 ms 980 KB Output is correct
28 Correct 23 ms 980 KB Output is correct
29 Correct 23 ms 1020 KB Output is correct
30 Correct 26 ms 980 KB Output is correct