Submission #124880

# Submission time Handle Problem Language Result Execution time Memory
124880 2019-07-04T05:13:56 Z 구재현(#3056) Kitchen (BOI19_kitchen) C++14
100 / 100
31 ms 764 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
using lint = long long;
using pi = pair<lint, int>;

int n, m, k;
int a[MAXN], b[MAXN], dp[MAXN];

int main(){
	cin >> n >> m >> k;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		if(a[i] < k){
			puts("Impossible");
			return 0;
		}
	}
	for(int i=1; i<=m; i++) cin >> b[i];
	fill(dp + 1, dp + MAXN, -1e9);
	dp[0] = 0;
	for(int i=1; i<=m; i++){
		for(int j=MAXN-1; j>=b[i]; j--){
			dp[j] = max(dp[j-b[i]] + min(b[i], n), dp[j]);
		}
	}
	int accm = accumulate(a + 1, a + n + 1, 0);
	int ret = 1e9;
	for(int i = accm; i < MAXN; i++){
		if(dp[i] >= n * k){
			cout << i - accm << endl;
			return 0;
		}
	}
	puts("Impossible");
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:28:6: warning: unused variable 'ret' [-Wunused-variable]
  int ret = 1e9;
      ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 764 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 3 ms 760 KB Output is correct
5 Correct 3 ms 760 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 764 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 3 ms 760 KB Output is correct
5 Correct 3 ms 760 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 4 ms 760 KB Output is correct
10 Correct 4 ms 760 KB Output is correct
11 Correct 4 ms 760 KB Output is correct
12 Correct 4 ms 760 KB Output is correct
13 Correct 4 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 760 KB Output is correct
2 Correct 24 ms 760 KB Output is correct
3 Correct 31 ms 764 KB Output is correct
4 Correct 31 ms 760 KB Output is correct
5 Correct 30 ms 764 KB Output is correct
6 Correct 22 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 760 KB Output is correct
2 Correct 6 ms 760 KB Output is correct
3 Correct 8 ms 760 KB Output is correct
4 Correct 6 ms 760 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 764 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 3 ms 760 KB Output is correct
5 Correct 3 ms 760 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 4 ms 760 KB Output is correct
10 Correct 4 ms 760 KB Output is correct
11 Correct 4 ms 760 KB Output is correct
12 Correct 4 ms 760 KB Output is correct
13 Correct 4 ms 760 KB Output is correct
14 Correct 27 ms 760 KB Output is correct
15 Correct 24 ms 760 KB Output is correct
16 Correct 31 ms 764 KB Output is correct
17 Correct 31 ms 760 KB Output is correct
18 Correct 30 ms 764 KB Output is correct
19 Correct 22 ms 760 KB Output is correct
20 Correct 7 ms 760 KB Output is correct
21 Correct 6 ms 760 KB Output is correct
22 Correct 8 ms 760 KB Output is correct
23 Correct 6 ms 760 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 22 ms 760 KB Output is correct
26 Correct 25 ms 764 KB Output is correct
27 Correct 18 ms 760 KB Output is correct
28 Correct 26 ms 760 KB Output is correct
29 Correct 26 ms 760 KB Output is correct
30 Correct 31 ms 760 KB Output is correct