Submission #125561

# Submission time Handle Problem Language Result Execution time Memory
125561 2019-07-05T23:53:23 Z eriksuenderhauf Kitchen (BOI19_kitchen) C++11
100 / 100
32 ms 636 KB
#include <bits/stdc++.h>
int a[301], b[301], dp[301*301], n, m, k, sm = 0;

int main() {
	scanf("%d %d %d", &n, &m, &k), dp[0] = 1;
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sm += a[i];
	for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
	if (*std::min_element(a+1,a+n+1) < k || m < k) return !printf("Impossible\n");
	for (int i = 1; i <= m; i++) for (int j = 301*301-1; j >= b[i]; j--)  if (dp[j-b[i]] > 0) dp[j] = std::max(dp[j], dp[j-b[i]] + std::min(b[i],n));
	for (int j = sm; j < 301*301; j++) if (dp[j] > n*k) return !printf("%d\n", j-sm);
	return !printf("Impossible\n");
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:5:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &m, &k), dp[0] = 1;
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
kitchen.cpp:6:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sm += a[i];
                               ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
kitchen.cpp:7:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
                               ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 252 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 632 KB Output is correct
2 Correct 22 ms 508 KB Output is correct
3 Correct 30 ms 536 KB Output is correct
4 Correct 32 ms 636 KB Output is correct
5 Correct 31 ms 632 KB Output is correct
6 Correct 21 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 252 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 26 ms 632 KB Output is correct
15 Correct 22 ms 508 KB Output is correct
16 Correct 30 ms 536 KB Output is correct
17 Correct 32 ms 636 KB Output is correct
18 Correct 31 ms 632 KB Output is correct
19 Correct 21 ms 504 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 20 ms 632 KB Output is correct
26 Correct 26 ms 504 KB Output is correct
27 Correct 16 ms 504 KB Output is correct
28 Correct 25 ms 504 KB Output is correct
29 Correct 26 ms 632 KB Output is correct
30 Correct 32 ms 604 KB Output is correct