Submission #124856

# Submission time Handle Problem Language Result Execution time Memory
124856 2019-07-04T04:37:31 Z 윤교준(#3050) Kitchen (BOI19_kitchen) C++14
20 / 100
33 ms 392 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[sz(V)-2])
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;
inline void fuk() { puts("Impossible"); exit(0); }

bitset<90005> D;

int A[305], B[305];

int N, M, K, Asum;

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> M >> K;
	if(M < K) fuk();
	for(int i = 1; i <= N; i++) {
		cin >> A[i];
		if(A[i] < K) fuk();
		Asum += A[i];
	}
	for(int i = 1; i <= M; i++) cin >> B[i];
	sort(B+1, B+M+1);

	D[0] = true;
	for(int i = 1, sum = 0; i <= M; i++) {
		for(int bsum = sum; 0 <= bsum; bsum--) {
				if(D[bsum])
					D[bsum+B[i]] = true;
		}
		sum += B[i];
	}

	for(int i = Asum; i < 90005; i++)
		if(D[i]) {
			cout << i-Asum << endl;
			exit(0);
		}
	fuk();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 380 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 380 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 376 KB Output is correct
2 Correct 16 ms 376 KB Output is correct
3 Correct 16 ms 376 KB Output is correct
4 Correct 33 ms 392 KB Output is correct
5 Correct 30 ms 376 KB Output is correct
6 Correct 11 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 380 KB Output isn't correct
5 Halted 0 ms 0 KB -