제출 #1224145

#제출 시각아이디문제언어결과실행 시간메모리
1224145sleepntsheepKitchen (BOI19_kitchen)C++17
컴파일 에러
0 ms0 KiB
#include <stdio.h>
#include <bitset>
#include <algorithm>

#define N 405

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

int dp[N * N];

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;
		}
	}

	memset(dp, 0xbf, sizeof dp);
	dp[0] = 0;
	for (int i = 1; i <= m; ++i) {
		scanf("%d", &b[i]);
		int x_ = b[i] < n ? b[i] : n, y_ = b[i];

		for (int j = N * N - 1; j >= y_; --j) {
			dp[j] = std::max(dp[j], dp[j - y_] + x_);
		}
	}

	for (int h = 0; h + sum < N * N; ++h) {
		if (dp[sum + h] >= k * n) {
			printf("%d\n", h);
			return 0;
		}
	}

	puts("Impossible");
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

kitchen.cpp: In function 'int main()':
kitchen.cpp:21:9: error: 'memset' was not declared in this scope
   21 |         memset(dp, 0xbf, sizeof dp);
      |         ^~~~~~
kitchen.cpp:4:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 | 
kitchen.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d%d%d", &n, &m, &k);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:14:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |                 scanf("%d", &a[i]), sum += a[i];
      |                 ~~~~~^~~~~~~~~~~~~
kitchen.cpp:24:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |                 scanf("%d", &b[i]);
      |                 ~~~~~^~~~~~~~~~~~~