답안 #926099

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
926099 2024-02-12T14:56:12 Z vjudge1 Kitchen (BOI19_kitchen) C++17
0 / 100
64 ms 92676 KB
#include<iostream>
#include<cassert>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<set>
#include<queue>
#include<map>
#include<iomanip>
#include<bitset>

using namespace std;

const int N = (int)4e5 + 7;
const int inf = (int)1e9 + 7;
const int MOD = (int)998244353;
const long long INF = (long long)1e18 + 7; 

int mult(int x, int y) {
	return 1ll*x*y%MOD;
}

int sum(int x, int y) {
	x += y;
	if(x >= MOD) {
		x -= MOD;
	}
	return x;
}

int sub(int x, int y) {
	x -= y;
	if(x < 0) {
		x += MOD;
	}
	return x;
}

int n, m, k;
int a[301], b[301], dp[301][90001];

int main() {	
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
	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];
	}
	if(m<k) {
		cout << "Impossible\n";
		return 0;
	}
	for(int i = 1; i <= n; ++i) {
		if(a[i] < k) {
			cout << "Impossible\n";
			return 0;
		}
	}
	for(int i = 0; i <= m; ++i) {
		for(int w = 0; w <= 9e4; ++w) {
			dp[i][w] = inf;
		}
	}
	dp[0][0] = 0;
	for(int i = 1; i <= m; ++i) {
		int x = min(n, b[i]);
		for(int w = x; w <= 9e4; ++w) {
			dp[i][w] = min(dp[i-1][w], dp[i-1][w-x]+b[i]);
		}
	}
	int ans = inf;
	for(int w = n*k; w <= 9e4; ++w) {
		if(dp[m][w] < inf) {
			ans = min(ans, dp[m][w]);
		}
	}
	if(ans == inf) {
		cout << "Impossible\n";
		return 0;
	}
	cout << ans-tot;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1376 KB Output is correct
2 Incorrect 2 ms 1376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1376 KB Output is correct
2 Incorrect 2 ms 1376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 64 ms 92676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 14688 KB Output is correct
2 Correct 10 ms 14688 KB Output is correct
3 Incorrect 10 ms 14692 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1376 KB Output is correct
2 Incorrect 2 ms 1376 KB Output isn't correct
3 Halted 0 ms 0 KB -