답안 #535484

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
535484 2022-03-10T11:16:52 Z new_acc Kitchen (BOI19_kitchen) C++14
100 / 100
26 ms 672 KB
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=300*300+10;
int pl[N];
int a[N],b[N];
void solve(){
	int n,m,k;
	cin>>n>>m>>k;
	int sum1=0,sum2=0,sum3=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]<k){
			cout<<"Impossible\n";
			return;	
		}
		sum1+=a[i];
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
		sum2+=b[i];
		sum3+=min(n,b[i]);
	}
	if(sum2<sum1 or sum3<n*k){
		cout<<"Impossible\n";
		return;
	}
	for(int i=1;i<=300*300;i++) pl[i]=-1;
	for(int i=1;i<=m;i++){
		for(int j=300*300;j>=0;j--)
			if(j+b[i]<=300*300 and pl[j]!=-1) pl[j+b[i]]=max(pl[j+b[i]],pl[j]+min(b[i],n));
	}
	for(int i=sum1;i<=300*300;i++){
		if(pl[i]>=n*k){
			cout<<i-sum1<<"\n";
			return;
		}
	}
}
int main(){
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 2 ms 568 KB Output is correct
10 Correct 2 ms 568 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 3 ms 596 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 596 KB Output is correct
2 Correct 18 ms 664 KB Output is correct
3 Correct 24 ms 656 KB Output is correct
4 Correct 24 ms 660 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 17 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 596 KB Output is correct
2 Correct 4 ms 660 KB Output is correct
3 Correct 5 ms 596 KB Output is correct
4 Correct 6 ms 596 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 2 ms 568 KB Output is correct
10 Correct 2 ms 568 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 3 ms 596 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 21 ms 596 KB Output is correct
15 Correct 18 ms 664 KB Output is correct
16 Correct 24 ms 656 KB Output is correct
17 Correct 24 ms 660 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 17 ms 596 KB Output is correct
20 Correct 6 ms 596 KB Output is correct
21 Correct 4 ms 660 KB Output is correct
22 Correct 5 ms 596 KB Output is correct
23 Correct 6 ms 596 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 15 ms 596 KB Output is correct
26 Correct 20 ms 672 KB Output is correct
27 Correct 12 ms 664 KB Output is correct
28 Correct 20 ms 596 KB Output is correct
29 Correct 22 ms 596 KB Output is correct
30 Correct 26 ms 596 KB Output is correct