답안 #724015

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724015 2023-04-14T15:31:38 Z lovrot Kitchen (BOI19_kitchen) C++17
21 / 100
34 ms 1012 KB
#include <cstdio>
#include <algorithm>

using namespace std; 

const int N = 310;
const int INF = 2e9;

int n, m, k, A[N], B[N]; 
int dp[2][N * N]; 

int main() {
	scanf("%d%d%d", &n, &m, &k); 
	int nim = INF, sum = 0;
	for(int i = 0; i < n; i++) {
		scanf("%d", A + i); 
		nim = min(nim, A[i]); 
		sum += A[i]; 
	}
	for(int i = 0; i < m; i++) scanf("%d", B + i); 

	if(nim < k || m < k) {
		printf("Impossible\n");
		return 0; 
	}
	bool f = 0;
	for(int i = 0; i < m; i++) {
		f ^= 1;
		for(int j = 0; j < N * N; j++) 
			dp[f][j] = max(dp[!f][j], B[i] > j ? 0 : dp[!f][j - B[i]] + min(n, B[i])); 
	}
	for(int i = 0; i < N * N; i++) 
		if(dp[f][i] >= n * k && i >= sum) {
			printf("%d\n", i - sum); 
			return 0; 
		}
	printf("Impossible\n");
	return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  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", A + i);
      |   ~~~~~^~~~~~~~~~~~~
kitchen.cpp:20:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  for(int i = 0; i < m; i++) scanf("%d", B + i);
      |                             ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 1012 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 980 KB Output is correct
2 Correct 6 ms 980 KB Output is correct
3 Correct 6 ms 980 KB Output is correct
4 Correct 6 ms 980 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -