답안 #950774

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
950774 2024-03-20T16:47:22 Z LCJLY Kitchen (BOI19_kitchen) C++14
0 / 100
37 ms 1884 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long 
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
typedef pair<pii,pii>pi2;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int dp[2][305*305];

void solve(){
	int n,m,k;
	cin >> n >> m >> k;
	
	int arr[n];
	int counter=0;
	bool amos=true;
	for(int x=0;x<n;x++){
		cin >> arr[x];
		counter+=arr[x];
		if(arr[x]<k) amos=false;
	}
	
	int chef[m];
	for(int x=0;x<m;x++){
		cin >> chef[x];
	}
	
	for(int x=1;x<305*305;x++){
		dp[0][x]=INT_MIN;
		dp[1][x]=INT_MIN;
	}
	
	
	for(int x=0;x<m;x++){
		for(int take=305*305-1;take>=0;take--){
			int nxt=take+chef[x];
			int add=dp[0][take]+min(chef[x],n);
			if(nxt<305*305){
				dp[1][nxt]=max(dp[1][nxt],add);
			}
		}
		for(int take=0;take<305*305;take++){
			dp[0][take]=dp[1][take];
			dp[1][take]=INT_MIN;
		}
	}
	
	int ans=1e15;
	for(int x=0;x<305*305;x++){
		//if(x<15) cout << dp[0][x] << " ";
		if(x>=counter&&dp[0][x]>=n*k){
			ans=min(ans,x-counter);
		}
	}
	
	if(ans>1e9||!amos){
		cout << "Impossible\n";
	}
	else cout << ans;
}	

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1880 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -