Submission #124857

# Submission time Handle Problem Language Result Execution time Memory
124857 2019-07-04T04:37:45 Z 김현수(#3337) Kitchen (BOI19_kitchen) C++14
51 / 100
31 ms 1528 KB
#include<bits/stdc++.h>
using namespace std;

const int N = 305, inf = 1e9;

int n, mt, m[2], a[2][N], k, s, dt[2][N*N], mn[N*N], ans = inf;

void boom () {
	puts("Impossible");
	exit(0);
}

int main()
{
	scanf("%d%d%d",&n,&mt,&k);
	for(int i=1;i<=n;i++) {
		int T;
		scanf("%d",&T);
		if(T < k) boom();
		s += T;
	}
	for(int i=1;i<=mt;i++) {
		int T;
		scanf("%d",&T);
		int I = (T >= k);
		a[I][++m[I]] = T;
	}
	for(int x=0;x<2;x++) {
		fill(dt[x] + 1, dt[x] + N*N, -inf);
		for(int i=1;i<=m[x];i++) {
			for(int j=N*N-1;j>=a[x][i];j--) {
				dt[x][j] = max(dt[x][j], dt[x][j-a[x][i]] + 1);
			}
		}
	}
	for(int i=N*N,j=N*N;i--;) {
		if(dt[0][i] >= 0) j = i;
		mn[i] = j;
	}
	for(int i=0;i<N*N;i++) {
		if(dt[1][i] < 0) continue;
		int X = max({0, s - i, (k - dt[1][i]) * n});
		if(mn[X] == N*N) continue;
		ans = min(ans, i + mn[X]);
	}
	if(ans == inf) boom();
	printf("%d\n", ans - s);
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&mt,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
kitchen.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&T);
   ~~~~~^~~~~~~~~
kitchen.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&T);
   ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1400 KB Output is correct
3 Correct 3 ms 1400 KB Output is correct
4 Correct 3 ms 1400 KB Output is correct
5 Correct 3 ms 1400 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1400 KB Output is correct
3 Correct 3 ms 1400 KB Output is correct
4 Correct 3 ms 1400 KB Output is correct
5 Correct 3 ms 1400 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 4 ms 1400 KB Output is correct
10 Correct 4 ms 1400 KB Output is correct
11 Correct 4 ms 1400 KB Output is correct
12 Correct 4 ms 1400 KB Output is correct
13 Correct 4 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1404 KB Output is correct
2 Correct 23 ms 1528 KB Output is correct
3 Correct 29 ms 1400 KB Output is correct
4 Correct 31 ms 1384 KB Output is correct
5 Correct 29 ms 1400 KB Output is correct
6 Correct 21 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1400 KB Output is correct
2 Incorrect 6 ms 1400 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1400 KB Output is correct
3 Correct 3 ms 1400 KB Output is correct
4 Correct 3 ms 1400 KB Output is correct
5 Correct 3 ms 1400 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 4 ms 1400 KB Output is correct
10 Correct 4 ms 1400 KB Output is correct
11 Correct 4 ms 1400 KB Output is correct
12 Correct 4 ms 1400 KB Output is correct
13 Correct 4 ms 1400 KB Output is correct
14 Correct 26 ms 1404 KB Output is correct
15 Correct 23 ms 1528 KB Output is correct
16 Correct 29 ms 1400 KB Output is correct
17 Correct 31 ms 1384 KB Output is correct
18 Correct 29 ms 1400 KB Output is correct
19 Correct 21 ms 1400 KB Output is correct
20 Correct 7 ms 1400 KB Output is correct
21 Incorrect 6 ms 1400 KB Output isn't correct
22 Halted 0 ms 0 KB -