답안 #796612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796612 2023-07-28T14:49:11 Z vjudge1 Kitchen (BOI19_kitchen) C++17
0 / 100
54 ms 136008 KB
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define int long long
//#define ld long double
using namespace std;
using ll=long long;
const int inf = 2e18;
const int MN = 305;
const int mod=1e9+7;
int n,m,k;
int a[MN],b[MN];
int dp[MN][MN*MN];
int mx,sum;
inline void solve() {
	cin>>n>>m>>k;
	for (int i=1; i<=n; i++) {
		cin>>a[i];
		if(a[i]<k) {
			cout<<"Impossible";
			return;
		}
		mx+=a[i];
	}
	for (int i=1; i<=m; i++) {
		cin>>b[i];
		sum+=b[i];
	}
	for (int i=1; i<=m; i++) {
		for (int w=sum; w>=0; w--) {
			dp[i][w]=dp[i-1][w];
			if(w+b[i]<=sum) dp[i][w+b[i]]=max(dp[i][w+b[i]],dp[i-1][w]+min(b[i],n));
		}
	}
	for (int i=0; i<=sum; i++) {
		if(dp[m][i]>=n*k) {
			cout<<sum-mx;
			return;
		}
	}
	cout<<"Impossible";
//	cout<<mn;
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
//	preprocess();
//	cin>>t;
	while(t--) {
		solve();
	}	
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 136008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -