답안 #950770

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
950770 2024-03-20T16:28:26 Z LCJLY Kitchen (BOI19_kitchen) C++14
9 / 100
1000 ms 262144 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 arr[45];
int n,m,k;
int chef[45];
int memo[45][45*305][45];
int counter=0;

int dp(int index, int take, int cnt){
	if(take>=max(counter,n*k) && cnt>=k) return take-counter;
	if(index==m) return INT_MAX;
	if(memo[index][take][cnt]!=-1) return memo[index][take][cnt];
	int ans=INT_MAX;
	ans=min(ans,dp(index+1,take,cnt));
	ans=min(ans,dp(index+1,take+chef[index],cnt+1));
	return memo[index][take][cnt]=ans;
}

void solve(){
	cin >> n >> m >> k;
	
	for(int x=0;x<n;x++){
		cin >> arr[x];
		counter+=arr[x];
	}
	
	for(int x=0;x<m;x++){
		cin >> chef[x];
	}
	
	memset(memo,-1,sizeof(memo));
	int hold=dp(0,0,0);
	
	for(int x=0;x<n;x++){
		if(arr[x]<k){
			cout << "Impossible\n";
			return;
		}
	}
	
	
	if(hold>1e8){
		cout << "Impossible\n";
	}
	else cout << hold;
}	

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 106 ms 217816 KB Output is correct
2 Correct 27 ms 217940 KB Output is correct
3 Correct 27 ms 217796 KB Output is correct
4 Correct 28 ms 217940 KB Output is correct
5 Correct 27 ms 217776 KB Output is correct
6 Correct 28 ms 217948 KB Output is correct
7 Correct 28 ms 217976 KB Output is correct
8 Correct 29 ms 217936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 106 ms 217816 KB Output is correct
2 Correct 27 ms 217940 KB Output is correct
3 Correct 27 ms 217796 KB Output is correct
4 Correct 28 ms 217940 KB Output is correct
5 Correct 27 ms 217776 KB Output is correct
6 Correct 28 ms 217948 KB Output is correct
7 Correct 28 ms 217976 KB Output is correct
8 Correct 29 ms 217936 KB Output is correct
9 Correct 29 ms 217868 KB Output is correct
10 Correct 28 ms 217904 KB Output is correct
11 Incorrect 27 ms 217960 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2315 ms 262144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 217936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 106 ms 217816 KB Output is correct
2 Correct 27 ms 217940 KB Output is correct
3 Correct 27 ms 217796 KB Output is correct
4 Correct 28 ms 217940 KB Output is correct
5 Correct 27 ms 217776 KB Output is correct
6 Correct 28 ms 217948 KB Output is correct
7 Correct 28 ms 217976 KB Output is correct
8 Correct 29 ms 217936 KB Output is correct
9 Correct 29 ms 217868 KB Output is correct
10 Correct 28 ms 217904 KB Output is correct
11 Incorrect 27 ms 217960 KB Output isn't correct
12 Halted 0 ms 0 KB -