Submission #522784

# Submission time Handle Problem Language Result Execution time Memory
522784 2022-02-05T19:16:11 Z LucaDantas Kitchen (BOI19_kitchen) C++17
0 / 100
1 ms 204 KB
#include <cstdio>
#include <algorithm>
using namespace std;
 
constexpr int maxn = 310, inf = 0x3f3f3f3f;
 
int a[maxn], b[maxn], ex[maxn];
 
int dp[maxn*maxn];
 
int main() {
	int n, m, k, soma = 0; scanf("%d %d %d", &n, &m, &k);
	for(int i = 0; i < n; i++)
		scanf("%d", a+i), soma += a[i];
	for(int i = 0; i < m; i++)
		scanf("%d", b+i);
 
	int ans = inf;
	for(int mask = 0; mask < (1 << m); mask++) {
		int tot = 0, bom = 0;
		for(int i = 0; i < m; i++)
			if(mask & (1 << i)) tot += b[i], bom += min(n, b[i]);
		if(tot >= soma && bom >= n*k) ans = min(ans, tot);
	}

	if(ans == inf) puts("impossible");
	else printf("%d\n", ans-soma);
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:12:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  int n, m, k, soma = 0; scanf("%d %d %d", &n, &m, &k);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", a+i), soma += a[i];
      |   ~~~~~^~~~~~~~~~~
kitchen.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", b+i);
      |   ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -