Submission #958171

# Submission time Handle Problem Language Result Execution time Memory
958171 2024-04-05T05:16:26 Z ezzzay Kitchen (BOI19_kitchen) C++14
100 / 100
36 ms 1072 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define ff first
#define ss second
const int N=309;
int a[N];
int b[N];
int dp[N*N];
signed main(){
    int n,m,k;
    cin>>n>>m>>k;
    int s=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        s+=a[i];
    }
    for(int i=1;i<=m;i++)cin>>b[i];
    
    for(int i=1;i<=n;i++){
        if(a[i]<k){
            cout<<"Impossible";
            return 0;
        }
    }
    for(int i=1;i<=m;i++){
        for(int j=90000;j>=b[i];j--){
            if(dp[j-b[i]]>0 or j-b[i]==0){
                dp[j]=max(dp[j],dp[j-b[i]]+min(b[i],n));
            }
        }
    }
    for(int i=s;i<=90000;i++){
        if(dp[i]>=n*k){
            cout<< i-s;
            return 0;
        }
    }
    cout<<"Impossible";
    
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 836 KB Output is correct
2 Correct 21 ms 860 KB Output is correct
3 Correct 28 ms 604 KB Output is correct
4 Correct 30 ms 1072 KB Output is correct
5 Correct 36 ms 1072 KB Output is correct
6 Correct 24 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 5 ms 440 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 6 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 24 ms 836 KB Output is correct
15 Correct 21 ms 860 KB Output is correct
16 Correct 28 ms 604 KB Output is correct
17 Correct 30 ms 1072 KB Output is correct
18 Correct 36 ms 1072 KB Output is correct
19 Correct 24 ms 720 KB Output is correct
20 Correct 4 ms 344 KB Output is correct
21 Correct 5 ms 440 KB Output is correct
22 Correct 4 ms 348 KB Output is correct
23 Correct 6 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 21 ms 860 KB Output is correct
26 Correct 34 ms 860 KB Output is correct
27 Correct 17 ms 600 KB Output is correct
28 Correct 24 ms 604 KB Output is correct
29 Correct 24 ms 856 KB Output is correct
30 Correct 30 ms 860 KB Output is correct