제출 #1220077

#제출 시각아이디문제언어결과실행 시간메모리
1220077jellybeanKitchen (BOI19_kitchen)C++20
20 / 100
95 ms211784 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
typedef pair<int,int> pii;

const int N = 305, M = 305;
int dp[M][90005], a[N], b[M];

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n,m,k; cin>>n>>m>>k;
	int tot = 0;
	for(int i=1; i<=n; i++) cin>>a[i], tot+=a[i];
	
	for(int i=1; i<=m; i++) cin>>b[i];
	
	dp[0][0] = 1;
	for(int i=1; i<=m; i++){
		for(int j=0; j<90005; j++){
			if(dp[i-1][j]) dp[i][j] = 1;
			else if(j-b[i] >= 0) dp[i][j] = dp[i-1][j-b[i]];
		}
	}
	
	int ans = -1;
	for(int i=tot; i<=90005; i++){
		if(dp[m][i]) {ans = i-tot; break;}
	}
	
	if(ans == -1) cout<<"Impossible";
	else cout<<ans;
	
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...