제출 #1224141

#제출 시각아이디문제언어결과실행 시간메모리
1224141sleepntsheepKitchen (BOI19_kitchen)C++17
30 / 100
8 ms14404 KiB
#include <stdio.h>
#include <bitset>

#define N 305

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

std::bitset<1606> dp[44][1606];

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

	dp[0][0][0] = 1;
	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 = 1600; j >= 0; --j)
			dp[i][j] = dp[i - 1][j];

		for (int j = 1600; j >= x_; --j)
			dp[i][j] |= dp[i - 1][j - x_] << y_;
	}


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

	puts("Impossible");
	return 0;
}

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

kitchen.cpp: In function 'int main()':
kitchen.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%d%d%d", &n, &m, &k);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:13:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |                 scanf("%d", &a[i]), sum += a[i];
      |                 ~~~~~^~~~~~~~~~~~~
kitchen.cpp:22:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |                 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...