Submission #595652

# Submission time Handle Problem Language Result Execution time Memory
595652 2022-07-13T22:54:13 Z UncoolAnon Kitchen (BOI19_kitchen) C++14
0 / 100
57 ms 24204 KB
#include <bits/stdc++.h> 
 
#define pii pair<int,int> 
#define F first 
#define S second 
#define mp make_pair 
 
using namespace std; 

const int inf=1e9; 

int main(){
	freopen("in.txt","r",stdin); 
	int n,m,k; 
	cin>>n>>m>>k;
	vector<int> a(n); 
	for(int&x:a) cin>>x; 
	vector<int> c(m); 
	for(int&x:c) cin>>x; 
	int s=0; 
	for(int&x:a){
		s+=x; 
		if(k>x){
			cout<<"Impossible"; 
			return 0; 
		}
	}
	vector<vector<int>> mem(m+1,vector<int>(300*300+1,-1)); 
	function<int(int,int)> dp=[&](int index,int sum){
		if(index==m&&sum==0) return 0; 
		if(index==m) return -inf;
		if(mem[index][sum]!=-1) return mem[index][sum];
		return mem[index][sum]=max(dp(index+1,sum),(sum>=c[index]?dp(index+1,sum-c[index])+min(c[index],n):-inf));
	}; 
	for(int i=s;i<=300*300;i++)
		if(dp(0,i)>=k*n){
			cout<<i-s;
			return 0; 
		}
	cout<<"Impossible";
	return 0; 
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen("in.txt","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 24200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 24200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 24204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 24204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 24200 KB Output isn't correct
2 Halted 0 ms 0 KB -