답안 #714554

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
714554 2023-03-25T04:52:58 Z amirhoseinfar1385 Kitchen (BOI19_kitchen) C++17
31 / 100
2 ms 320 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	int n,m,k;
	cin>>n>>m>>k;
	vector<int>alln(n),allm(m);
	int f=0;
	int sumn=0;
	for(int i=0;i<n;i++){
		cin>>alln[i];
		if(alln[i]<k){
			f=1;
		}
		sumn+=alln[i];
	}
	int summ=0,mainsumm=0;
	for(int i=0;i<m;i++){
		cin>>allm[i];
		summ+=min(allm[i],n);
		mainsumm+=allm[i];
	}
	if(f==1||summ<n*k||mainsumm<sumn){
		cout<<"Impossible\n";
		return 0;
	}
	int res=1e9+5;
	for(int i=0;i<(1<<m);i++){
		summ=0,mainsumm=0;
		for(int j=0;j<m;j++){
			if((i>>j)&1){
				summ+=min(allm[j],n);
				mainsumm+=allm[j];
			}
		}
		if(summ>=n*k&&mainsumm>=sumn){
			res=min(res,mainsumm-sumn);
		}
	}
	cout<<res<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 216 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 216 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 2 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 216 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 2 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Incorrect 0 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -