답안 #595634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595634 2022-07-13T22:27:42 Z UncoolAnon Kitchen (BOI19_kitchen) C++14
21 / 100
132 ms 93056 KB
#include <bits/stdc++.h> 

#define pii pair<int,int> 
#define F first 
#define S second 
#define mp make_pair 

using namespace std; 

int main(){
	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) return 0; 
		if(mem[index][sum]!=-1) return mem[index][sum];
		return mem[index][sum]=max(dp(index+1,sum),(c[index]<=sum?dp(index+1,sum-c[index])+min(c[index],n):-(int)1e9));
	}; 
	for(int i=s;i<=300*300+1;i++)
		if(dp(0,i)>=k*n){
			cout<<i-s;
			return 0; 
		}
	cout<<"Impossible";
	return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1620 KB Output is correct
2 Incorrect 1 ms 1620 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1620 KB Output is correct
2 Incorrect 1 ms 1620 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 132 ms 93056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 15020 KB Output is correct
2 Correct 12 ms 15060 KB Output is correct
3 Correct 7 ms 15124 KB Output is correct
4 Correct 10 ms 15036 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1620 KB Output is correct
2 Incorrect 1 ms 1620 KB Output isn't correct
3 Halted 0 ms 0 KB -