Submission #1224140

#TimeUsernameProblemLanguageResultExecution timeMemory
1224140sleepntsheepKitchen (BOI19_kitchen)C++17
31 / 100
2 ms328 KiB
#include <stdio.h>

#define N 305

int n, m, k, a[N], b[N], sum, ans = 1e9;

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]), sum += a[i];
		if (a[i] < k) {
			puts("Impossible");
			return 0;
		}
	}
	for (int i = 0; i < m; ++i)
		scanf("%d", &b[i]);

	for (int x = 0; x < (1 << m); ++x) {
		if (__builtin_popcount(x) < k)
			continue;
		int s1, s2;
		s1 = s2 = 0;
		for (int j = 0; j < m; ++j) {
			if ((x >> j) & 1) {
				s1 += b[j] < n ? b[j]: n;
				s2 += b[j];
			}
		}
		if (s1 / n >= k && s2 >= sum && s2 - sum < ans) {
			ans = s2 - sum;
		}
	}
	if (ans == 1e9)
		puts("Impossible");
	else
		printf("%d\n", ans);

	return 0;
}

Compilation message (stderr)

kitchen.cpp: In function 'int main()':
kitchen.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         scanf("%d%d%d", &n, &m, &k);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:10:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |                 scanf("%d", &a[i]), sum += a[i];
      |                 ~~~~~^~~~~~~~~~~~~
kitchen.cpp:17:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |                 scanf("%d", &b[i]);
      |                 ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...