답안 #796637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796637 2023-07-28T15:04:20 Z vjudge1 Kitchen (BOI19_kitchen) C++17
21 / 100
62 ms 136036 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=mx; i<=sum; i++) {
		if(dp[m][i]>=n*k) {
			cout<<i-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 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 62 ms 136036 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 712 KB Output is correct
3 Correct 1 ms 844 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -