Submission #955605

# Submission time Handle Problem Language Result Execution time Memory
955605 2024-03-31T05:43:37 Z Batorgil952 Kitchen (BOI19_kitchen) C++14
21 / 100
64 ms 94804 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][j]=max(dp[i][j], dp[i-1][j-b[i]]+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 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2648 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2648 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 94804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 16728 KB Output is correct
2 Correct 6 ms 16732 KB Output is correct
3 Correct 6 ms 16728 KB Output is correct
4 Correct 6 ms 16732 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2648 KB Output isn't correct
3 Halted 0 ms 0 KB -