답안 #921125

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921125 2024-02-03T10:31:14 Z shoryu386 Kitchen (BOI19_kitchen) C++17
21 / 100
1000 ms 18524 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n, m, k; cin >> n >> m >> k;
	
	int buckets[n], balls[m];
	
	for (int x = 0; x < n; x++) cin >> buckets[x];
	for (int x = 0; x < m; x++) cin >> balls[x];
	
	#define IMP cout << "Impossible"; return 0;
	
	bool dead = false;
	for (int x = 0; x < n; x++){
		if (buckets[x] < k){
			dead = true;
		}
	}
	if (dead) {IMP;}
	
	int bucketsum = 0;
	for (int x = 0; x < n; x++){
		bucketsum += buckets[x];
	}
	
	
	#define BSMAX 100000
	bitset<BSMAX> hmm[n*k+1];
	
	hmm[n*k][0] = 1;
	sort(balls, balls+m, greater<int>());
	
	int sum = 0, ssum[m];
	for (int x = m-1; x > -1; x--){
		sum += min(n, balls[x]);
		ssum[x] = sum;
	}
	
	sum = 0; int psum[m];
	for (int x = 0; x < m; x++){
		sum += balls[x];
		psum[x] = sum;
	}
	
	for (int z = n*k; z <= n*k; z++){
		hmm[max(0LL, z - min(balls[0], n))] |= (hmm[z] << balls[0]);
	}
	
	for (int x = 1; x < m; x++){
		for (int z = n*k - psum[x-1]; z <= min(n*k, ssum[x]); z++){
			hmm[max(0LL, z - min(balls[x], n))] |= (hmm[z] << balls[x]);
		}
	}
	
	int ans = -1;
	for (int x = bucketsum; x < BSMAX; x++){
		if (hmm[0][x]){
			ans = x-bucketsum;
			break;
		}
	}
		
	if (ans == -1) cout << "Impossible";
	else cout << ans;
	
}

Compilation message

kitchen.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 3 ms 4156 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 3 ms 4156 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1042 ms 4444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 9816 KB Output is correct
2 Correct 20 ms 8540 KB Output is correct
3 Correct 43 ms 9044 KB Output is correct
4 Correct 13 ms 18524 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 3 ms 4156 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -