답안 #124863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124863 2019-07-04T04:50:54 Z 구재현(#3056) Kitchen (BOI19_kitchen) C++14
41 / 100
10 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 505;
using lint = long long;
using pi = pair<lint, int>;

int n, m, k;
int a[MAXN], b[MAXN];

int main(){
	cin >> n >> m >> k;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		if(a[i] < k){
			puts("Impossible");
			return 0;
		}
	}
	for(int i=1; i<=m; i++) cin >> b[i];
	sort(b + 1, b + m + 1);
	int acc = accumulate(a + 1, a + n + 1, 0);
	int l = lower_bound(b + 1, b + m + 1, n) - b;
	bitset<160001> dp;
	dp[0] = 1;
	for(int i=1; i<l; i++){
		dp = (dp << b[i]) | dp;
	}
	int ret = 1e9;
	for(int i=0; i<=160000; i++){
		if(!dp[i]) continue;
		int sum = i;
		int minSum = i;
		for(int j = l; j <= m; j++){
			if(minSum >= n * k && sum >= acc) break;
			minSum += n;
			sum += b[j];
		}
		if(minSum >= n * k && sum >= acc){
			ret = min(ret, sum);
		}
	}
	if(ret > 1e8) puts("Impossible");
	else cout << ret - acc << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 10 ms 376 KB Output is correct
5 Correct 7 ms 348 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -