답안 #535480

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
535480 2022-03-10T11:09:56 Z new_acc Kitchen (BOI19_kitchen) C++14
20 / 100
25 ms 664 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];
		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 Incorrect 1 ms 564 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 1 ms 564 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 596 KB Output is correct
2 Correct 21 ms 596 KB Output is correct
3 Correct 24 ms 596 KB Output is correct
4 Correct 25 ms 564 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 19 ms 664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 4 ms 596 KB Output is correct
3 Correct 6 ms 596 KB Output is correct
4 Correct 4 ms 596 KB Output is correct
5 Incorrect 4 ms 596 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 1 ms 564 KB Output isn't correct
8 Halted 0 ms 0 KB -