답안 #957724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957724 2024-04-04T08:49:47 Z batsukh2006 Kitchen (BOI19_kitchen) C++17
100 / 100
27 ms 1368 KB
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
#include<utility>
#include<set>
#include<cmath>
#include<queue>
#include<deque>
#include<functional>
#include<stack>
#include<limits.h>
#include<iomanip>
#include<unordered_map> 
#include<numeric>
#include<tuple>
#include<bitset>
using namespace std;
 
#define MOD 1000000007
#define int long long
#define ss second
#define ff first
#define endl '\n'
typedef pair<int,int> pp;
const int mxN=9e4+1;
vector<int> dp(mxN);
signed main(){
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n,m,k; cin>>n>>m>>k;
	vector<int> a(n+1),b(m+1);
	for(int i=1; i<=n; i++) cin>>a[i];
	for(int i=1; i<=m; i++) cin>>b[i];
	int sum=0;
	for(int i=1; i<=n; i++){
		sum+=a[i];
		if(a[i]<k){
			cout<<"Impossible";
			return 0;
		}
	}
	for(int i=1; i<=m; i++){
		for(int k=mxN; k>=b[i]; k--){
			if(dp[k-b[i]]>0||k-b[i]==0){
				dp[k]=max(dp[k],dp[k-b[i]]+min(b[i],n));
			}
		}
	}
	for(int i=sum; i<mxN; i++){
		if(dp[i]>=n*k){
			cout<<i-sum;
			return 0;
		}
	}
	cout<<"Impossible";
    return 0;
}

























# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1272 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1112 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1272 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1112 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 1116 KB Output is correct
2 Correct 15 ms 1116 KB Output is correct
3 Correct 23 ms 1116 KB Output is correct
4 Correct 27 ms 1112 KB Output is correct
5 Correct 23 ms 1112 KB Output is correct
6 Correct 14 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1116 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 3 ms 1116 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1272 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1112 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 18 ms 1116 KB Output is correct
15 Correct 15 ms 1116 KB Output is correct
16 Correct 23 ms 1116 KB Output is correct
17 Correct 27 ms 1112 KB Output is correct
18 Correct 23 ms 1112 KB Output is correct
19 Correct 14 ms 1116 KB Output is correct
20 Correct 3 ms 1116 KB Output is correct
21 Correct 3 ms 1116 KB Output is correct
22 Correct 3 ms 1116 KB Output is correct
23 Correct 3 ms 1116 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 13 ms 1116 KB Output is correct
26 Correct 27 ms 1116 KB Output is correct
27 Correct 16 ms 1368 KB Output is correct
28 Correct 18 ms 1116 KB Output is correct
29 Correct 23 ms 1116 KB Output is correct
30 Correct 25 ms 1116 KB Output is correct