답안 #546195

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546195 2022-04-06T15:51:31 Z MilosMilutinovic Kitchen (BOI19_kitchen) C++14
0 / 100
83 ms 92128 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;

	scanf("%d%d%d", &n, &m, &k);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]), s += aa[i];
	for (i = 0; i < m; i++)
		scanf("%d", &bb[i]);
	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[n][i] >= n * k)
			ans = i - s;
	if (ans == -1)
		printf("Impossible");
	else
		printf("%d", ans);
	return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d%d%d", &n, &m, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", &aa[i]), s += aa[i];
      |   ~~~~~^~~~~~~~~~~~~~
kitchen.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%d", &bb[i]);
      |   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 83 ms 92128 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 14360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -