답안 #402648

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
402648 2021-05-12T07:52:10 Z Nicholas_Patrick Kitchen (BOI19_kitchen) C++17
100 / 100
891 ms 13544 KB
#include <cstdio>
#include <queue>
#include <bitset>
#include <algorithm>
using namespace std;

const int maxall=300;
const int maxrow=maxall*maxall+1;
int main(){
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	vector<int> a(n), b(m);
	int A=0;
	for(int& i: a){
		scanf("%d", &i);
		A+=i;
	}
	for(int& i: b)
		scanf("%d", &i);
	if(*min_element(a.begin(), a.end())<k){
		printf("Impossible\n");
		return 0;
	}
	sort(b.begin(), b.end());
	auto it=upper_bound(b.begin(), b.end(), n);
	bitset<maxrow> smallsums;
	smallsums[0]=true;
	for(auto i=b.begin(); i!=it; i++)
		smallsums|=smallsums<<*i;
	bitset<maxrow*(maxall+1)> mask;
	for(int i=0; i<maxrow; i++)
		mask[i+maxrow*min(i/n, k)]=smallsums[i];
	//bottleneck
	for(auto i=it; i!=b.end(); i++)
		mask|=mask<<(maxrow+*i)|mask<<*i;
	for(int i=A; i<maxrow; i++){
		if(mask[i+k*maxrow]){
			printf("%d\n", i-A);
			return 0;
		}
	}
	printf("Impossible\n");
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d%d%d", &n, &m, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d", &i);
      |   ~~~~~^~~~~~~~~~
kitchen.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%d", &i);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 13516 KB Output is correct
2 Correct 15 ms 13544 KB Output is correct
3 Correct 15 ms 13516 KB Output is correct
4 Correct 17 ms 13460 KB Output is correct
5 Correct 9 ms 13516 KB Output is correct
6 Correct 9 ms 13516 KB Output is correct
7 Correct 7 ms 13516 KB Output is correct
8 Correct 16 ms 13532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 13516 KB Output is correct
2 Correct 15 ms 13544 KB Output is correct
3 Correct 15 ms 13516 KB Output is correct
4 Correct 17 ms 13460 KB Output is correct
5 Correct 9 ms 13516 KB Output is correct
6 Correct 9 ms 13516 KB Output is correct
7 Correct 7 ms 13516 KB Output is correct
8 Correct 16 ms 13532 KB Output is correct
9 Correct 57 ms 13516 KB Output is correct
10 Correct 59 ms 13516 KB Output is correct
11 Correct 35 ms 13512 KB Output is correct
12 Correct 8 ms 13516 KB Output is correct
13 Correct 8 ms 13516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 13428 KB Output is correct
2 Correct 9 ms 13516 KB Output is correct
3 Correct 36 ms 13516 KB Output is correct
4 Correct 371 ms 13544 KB Output is correct
5 Correct 11 ms 13516 KB Output is correct
6 Correct 9 ms 13544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 135 ms 13532 KB Output is correct
2 Correct 79 ms 13520 KB Output is correct
3 Correct 8 ms 13536 KB Output is correct
4 Correct 8 ms 13544 KB Output is correct
5 Correct 7 ms 13540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 13516 KB Output is correct
2 Correct 15 ms 13544 KB Output is correct
3 Correct 15 ms 13516 KB Output is correct
4 Correct 17 ms 13460 KB Output is correct
5 Correct 9 ms 13516 KB Output is correct
6 Correct 9 ms 13516 KB Output is correct
7 Correct 7 ms 13516 KB Output is correct
8 Correct 16 ms 13532 KB Output is correct
9 Correct 57 ms 13516 KB Output is correct
10 Correct 59 ms 13516 KB Output is correct
11 Correct 35 ms 13512 KB Output is correct
12 Correct 8 ms 13516 KB Output is correct
13 Correct 8 ms 13516 KB Output is correct
14 Correct 8 ms 13428 KB Output is correct
15 Correct 9 ms 13516 KB Output is correct
16 Correct 36 ms 13516 KB Output is correct
17 Correct 371 ms 13544 KB Output is correct
18 Correct 11 ms 13516 KB Output is correct
19 Correct 9 ms 13544 KB Output is correct
20 Correct 135 ms 13532 KB Output is correct
21 Correct 79 ms 13520 KB Output is correct
22 Correct 8 ms 13536 KB Output is correct
23 Correct 8 ms 13544 KB Output is correct
24 Correct 7 ms 13540 KB Output is correct
25 Correct 691 ms 13524 KB Output is correct
26 Correct 612 ms 13520 KB Output is correct
27 Correct 370 ms 13492 KB Output is correct
28 Correct 457 ms 13520 KB Output is correct
29 Correct 891 ms 13528 KB Output is correct
30 Correct 498 ms 13524 KB Output is correct