Submission #956132

# Submission time Handle Problem Language Result Execution time Memory
956132 2024-04-01T06:31:12 Z Batorgil952 Kitchen (BOI19_kitchen) C++14
100 / 100
81 ms 107604 KB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair

using namespace std;

const int N=302;
int a[N], b[N];
int dp[N][N*N];

int main(){
	int n, m, k, i, j, s, ans, ind;
	
	scanf("%d",&n);
	scanf("%d",&m);
	scanf("%d",&k);
	
	s=0;
	ind=0;
	for(i=1; i<=n; i++){
		scanf("%d",&a[i]);
		s+=a[i];
		if(a[i]<k) ind++;
	}
	
	for(i=1; i<=m; i++){
		scanf("%d",&b[i]);
	}
	
	if(ind!=0){
		printf("Impossible\n");
		return 0;
	}
	
	for(i=1; i<=m; i++){
		for(j=1; j<=90000; j++){
			dp[i][j]=dp[i-1][j];
			if(j-b[i]>0 && dp[i-1][j-b[i]]>0){
				dp[i][j]=max(dp[i][j], dp[i-1][j-b[i]]+min(n, b[i]));
			}
			else if(j-b[i]==0){
				dp[i][j]=max(dp[i][j], min(n, b[i]));
			}
		}
	}
	
	ans=-1;
	for(i=1; i<=90000; i++){
		if(dp[m][i]>=n*k && i>=s){
			if(ans==-1) ans=i-s;
			else ans=min(ans, i-s);
		}
	}
	
	if(ans==-1) printf("Impossible\n");
	else printf("%d\n", ans);
	
	return 0;
}

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]
   15 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
kitchen.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%d",&m);
      |  ~~~~~^~~~~~~~~
kitchen.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d",&k);
      |  ~~~~~^~~~~~~~~
kitchen.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%d",&a[i]);
      |   ~~~~~^~~~~~~~~~~~
kitchen.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |   scanf("%d",&b[i]);
      |   ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 3 ms 6488 KB Output is correct
10 Correct 3 ms 6492 KB Output is correct
11 Correct 3 ms 6596 KB Output is correct
12 Correct 3 ms 6488 KB Output is correct
13 Correct 3 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 94936 KB Output is correct
2 Correct 39 ms 82260 KB Output is correct
3 Correct 52 ms 107600 KB Output is correct
4 Correct 45 ms 107604 KB Output is correct
5 Correct 45 ms 105040 KB Output is correct
6 Correct 32 ms 76112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 16728 KB Output is correct
2 Correct 7 ms 16732 KB Output is correct
3 Correct 8 ms 16732 KB Output is correct
4 Correct 7 ms 16728 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 3 ms 6488 KB Output is correct
10 Correct 3 ms 6492 KB Output is correct
11 Correct 3 ms 6596 KB Output is correct
12 Correct 3 ms 6488 KB Output is correct
13 Correct 3 ms 6492 KB Output is correct
14 Correct 81 ms 94936 KB Output is correct
15 Correct 39 ms 82260 KB Output is correct
16 Correct 52 ms 107600 KB Output is correct
17 Correct 45 ms 107604 KB Output is correct
18 Correct 45 ms 105040 KB Output is correct
19 Correct 32 ms 76112 KB Output is correct
20 Correct 7 ms 16728 KB Output is correct
21 Correct 7 ms 16732 KB Output is correct
22 Correct 8 ms 16732 KB Output is correct
23 Correct 7 ms 16728 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 32 ms 76116 KB Output is correct
26 Correct 39 ms 88660 KB Output is correct
27 Correct 24 ms 57692 KB Output is correct
28 Correct 37 ms 88624 KB Output is correct
29 Correct 38 ms 90708 KB Output is correct
30 Correct 47 ms 107600 KB Output is correct