답안 #298432

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
298432 2020-09-12T20:50:42 Z peuch Kitchen (BOI19_kitchen) C++17
0 / 100
1 ms 384 KB
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 310;

int n, m, k;
int a[MAXN], b[MAXN];
int sum;

int main(){
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	for(int i = 1; i <= m; i++) scanf("%d", &b[i]);
	if(k > m) {
		printf("Impossible\n");
		return 0;
	}
	if(k == m && k == 2) {
		if(b[1] >= n && b[2] >= n && b[1] + b[2] >= sum){
			printf("%d\n", b[1] + b[2] - sum);
			return 0;
		}
		printf("Impossible\n");
		return 0;
	}
	else if(k == m && k == 1){
		if(b[1] >= sum){
			printf("%d\n", b[1] - sum);
			return 0;
		}
		printf("Impossible\n");
		return 0;
	}
	else if(m == k + 1){
		if(b[1] >= sum && b[2] >= sum){
			printf("%d", min(b[1], b[2]) - sum);
			return 0;
		}
		else if(b[1] >= sum || b[2] >= sum){
			printf("%d\n", max(b[1], b[2]) - sum);
			return 0;
		}
		printf("Impossible\n");
		return 0;
	}
	printf("Impossible\n");
	return 0;
}

Compilation message

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