답안 #385291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
385291 2021-04-04T03:25:06 Z rqi Kitchen (BOI19_kitchen) C++14
31 / 100
4 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

void ckmin(int& a, int b){
	a = min(a, b);
}

const int MOD = 1e9+7;

const int mx = 305;
int N, M, K;

int Asum = 0;
int A[mx];
int B[mx];
int Bp[mx];

int main(){
	cin >> N >> M >> K;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		Asum+=A[i];
	}
	for(int i = 0; i < M; i++){
		cin >> B[i];
	}

	for(int i = 0; i < N; i++){
		if(A[i] < K){
			cout << "Impossible" << "\n";
			exit(0);
		}
	}

	for(int i = 0; i < M; i++){
		Bp[i] = min(B[i], N);
	}

	if(M <= 15){
		int ans = MOD;
		for(int i = 0; i < (1<<M); i++){
			int Bsum = 0;
			int Bpsum = 0;

			for(int j = 0; j < M; j++){
				if((i>>j)&1){
					Bsum+=B[j];
					Bpsum+=Bp[j];
				}
			}

			if(Bsum >= Asum && Bpsum >= N*K){
				ckmin(ans, Bsum);
			}
		}

		if(ans == MOD){
			cout << "Impossible" << "\n";
		}
		else{
			cout << ans-Asum << "\n";
		}
		exit(0);
	}
	

	

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
10 Correct 4 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
10 Correct 4 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Incorrect 2 ms 364 KB Output isn't correct
15 Halted 0 ms 0 KB -