답안 #566866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
566866 2022-05-23T04:38:56 Z inluminas Kitchen (BOI19_kitchen) C++17
100 / 100
54 ms 680 KB
#include"bits/stdc++.h"
using namespace std;

#define ll long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false)
#define inf LLONG_MAX
#define l first
#define r second

const int lmt=90001;
int val[lmt];

int main(){
	fastio;

	int n,m,k;
	cin>>n>>m>>k;
	int a[n+1],b[m+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=m;i++) cin>>b[i];
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	ll sum=0;
	for(int i=1;i<=n;i++){
		if(a[i]<k){
			cout<<"Impossible"<<endl;
			return 0;
		}
		sum+=a[i];
	}

	for(int i=1;i<lmt;i++) val[i]=-1;

	for(int i=1;i<=m;i++){
		for(int j=lmt-1;j>=0;j--){
			if(val[j]==-1 || j+b[i]>=lmt) continue;
			val[j+b[i]]=max(val[j+b[i]],val[j]+min(n,b[i]));
		}
	}


	ll ans=inf;

	for(int i=sum;i<lmt;i++){
		if(val[i]<n*k) continue;
		ans=min(ans,i-sum);
	}

	if(ans==inf){
		cout<<"Impossible"<<endl;
		return 0;
	}

	cout<<ans<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 576 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 576 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 3 ms 580 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 596 KB Output is correct
2 Correct 26 ms 596 KB Output is correct
3 Correct 38 ms 588 KB Output is correct
4 Correct 54 ms 664 KB Output is correct
5 Correct 44 ms 588 KB Output is correct
6 Correct 18 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 588 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 4 ms 680 KB Output is correct
4 Correct 4 ms 596 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 576 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 3 ms 580 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 19 ms 596 KB Output is correct
15 Correct 26 ms 596 KB Output is correct
16 Correct 38 ms 588 KB Output is correct
17 Correct 54 ms 664 KB Output is correct
18 Correct 44 ms 588 KB Output is correct
19 Correct 18 ms 596 KB Output is correct
20 Correct 3 ms 588 KB Output is correct
21 Correct 3 ms 596 KB Output is correct
22 Correct 4 ms 680 KB Output is correct
23 Correct 4 ms 596 KB Output is correct
24 Correct 1 ms 324 KB Output is correct
25 Correct 15 ms 680 KB Output is correct
26 Correct 31 ms 588 KB Output is correct
27 Correct 20 ms 664 KB Output is correct
28 Correct 40 ms 652 KB Output is correct
29 Correct 40 ms 656 KB Output is correct
30 Correct 52 ms 660 KB Output is correct