답안 #546203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546203 2022-04-06T16:04:04 Z MilosMilutinovic Kitchen (BOI19_kitchen) C
100 / 100
92 ms 105992 KB
#include <stdio.h>

#define N	300
#define N_	90000
#define INF	0x3f3f3f

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int main() {
	static int aa[N], bb[N], dp[N][N_];
	int n, m, k, i, j, s, mn;

	scanf("%d%d%d", &n, &m, &k);
	for (i = 0, s = 0; i < n; i++)
		scanf("%d", &aa[i]), s += aa[i];
	for (i = 0; i < m; i++)
		scanf("%d", &bb[i]);
	mn = aa[0];
	for (i = 1; i < n; i++)
		mn = min(mn, aa[i]);
	if (mn < k) {
		printf("Impossible");
		return 0;
	}
	for (i = 0; i < m; i++)
		for (j = 0; j < N_; j++)
			dp[i][j] = -INF;
	dp[0][0] = 0;
	dp[0][bb[0]] = min(n, bb[0]);
	for (i = 1; i < m; i++)
		for (j = 0; j < N_; j++)
			dp[i][j] = max(dp[i - 1][j], (bb[i] <= j ? dp[i - 1][j - bb[i]] + min(n, bb[i]) : -INF));
	int ans = -1;
	for (i = N_ - 1; i >= s; i--)
		if (dp[m - 1][i] >= n * k)
			ans = i - s;
	if (ans == -1)
		printf("Impossible");
	else
		printf("%d", ans);
	return 0;
}

Compilation message

kitchen.c: In function 'main':
kitchen.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d%d%d", &n, &m, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
kitchen.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", &aa[i]), s += aa[i];
      |   ^~~~~~~~~~~~~~~~~~~
kitchen.c:18:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%d", &bb[i]);
      |   ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 5 ms 5504 KB Output is correct
10 Correct 5 ms 5572 KB Output is correct
11 Correct 4 ms 5460 KB Output is correct
12 Correct 4 ms 5460 KB Output is correct
13 Correct 4 ms 5504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 92112 KB Output is correct
2 Correct 64 ms 79880 KB Output is correct
3 Correct 88 ms 105840 KB Output is correct
4 Correct 92 ms 105932 KB Output is correct
5 Correct 84 ms 102420 KB Output is correct
6 Correct 57 ms 73484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 14292 KB Output is correct
2 Correct 11 ms 14292 KB Output is correct
3 Correct 11 ms 14364 KB Output is correct
4 Correct 12 ms 14380 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 5 ms 5504 KB Output is correct
10 Correct 5 ms 5572 KB Output is correct
11 Correct 4 ms 5460 KB Output is correct
12 Correct 4 ms 5460 KB Output is correct
13 Correct 4 ms 5504 KB Output is correct
14 Correct 73 ms 92112 KB Output is correct
15 Correct 64 ms 79880 KB Output is correct
16 Correct 88 ms 105840 KB Output is correct
17 Correct 92 ms 105932 KB Output is correct
18 Correct 84 ms 102420 KB Output is correct
19 Correct 57 ms 73484 KB Output is correct
20 Correct 11 ms 14292 KB Output is correct
21 Correct 11 ms 14292 KB Output is correct
22 Correct 11 ms 14364 KB Output is correct
23 Correct 12 ms 14380 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 74 ms 74240 KB Output is correct
26 Correct 70 ms 85800 KB Output is correct
27 Correct 44 ms 56552 KB Output is correct
28 Correct 80 ms 86192 KB Output is correct
29 Correct 69 ms 88448 KB Output is correct
30 Correct 86 ms 105992 KB Output is correct