답안 #544746

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
544746 2022-04-02T16:25:44 Z rainboy Kitchen (BOI19_kitchen) C
100 / 100
28 ms 640 KB
#include <stdio.h>
#include <string.h>

#define N	300
#define M	300
#define K	300
#define B	300
#define S	(M * B)

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 dp[S + 1];
	int n, m, k, i, s, s_;

	scanf("%d%d%d", &n, &m, &k);
	if (m < k) {
		printf("Impossible\n");
		return 0;
	}
	s_ = 0;
	for (i = 0; i < n; i++) {
		int a;

		scanf("%d", &a);
		if (a < k) {
			printf("Impossible\n");
			return 0;
		}
		s_ += a;
	}
	memset(dp, -1, sizeof dp), dp[0] = 0;
	while (m--) {
		int b;

		scanf("%d", &b);
		for (s = S; s >= b; s--)
			if (dp[s - b] != -1)
				dp[s] = max(dp[s], dp[s - b] + min(b, n));
	}
	for (s = s_; s <= S; s++)
		if (dp[s] >= n * k) {
			printf("%d\n", s - s_);
			return 0;
		}
	printf("Impossible\n");
	return 0;
}

Compilation message

kitchen.c: In function 'main':
kitchen.c:17:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d%d%d", &n, &m, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
kitchen.c:26:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d", &a);
      |   ^~~~~~~~~~~~~~~
kitchen.c:37:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   scanf("%d", &b);
      |   ^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 548 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 544 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 548 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 544 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 2 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 548 KB Output is correct
2 Correct 16 ms 548 KB Output is correct
3 Correct 21 ms 596 KB Output is correct
4 Correct 27 ms 596 KB Output is correct
5 Correct 25 ms 636 KB Output is correct
6 Correct 28 ms 628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 4 ms 640 KB Output is correct
3 Correct 4 ms 596 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 548 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 544 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 2 ms 548 KB Output is correct
14 Correct 18 ms 548 KB Output is correct
15 Correct 16 ms 548 KB Output is correct
16 Correct 21 ms 596 KB Output is correct
17 Correct 27 ms 596 KB Output is correct
18 Correct 25 ms 636 KB Output is correct
19 Correct 28 ms 628 KB Output is correct
20 Correct 3 ms 596 KB Output is correct
21 Correct 4 ms 640 KB Output is correct
22 Correct 4 ms 596 KB Output is correct
23 Correct 3 ms 596 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 15 ms 544 KB Output is correct
26 Correct 19 ms 596 KB Output is correct
27 Correct 11 ms 640 KB Output is correct
28 Correct 19 ms 640 KB Output is correct
29 Correct 21 ms 596 KB Output is correct
30 Correct 24 ms 596 KB Output is correct