Submission #949958

# Submission time Handle Problem Language Result Execution time Memory
949958 2024-03-20T01:13:22 Z Darren0724 Kitchen (BOI19_kitchen) C++17
100 / 100
35 ms 860 KB
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define all(x) x.begin(), x.end()
#define endl '\n'
#define no cout<<"Impossible"<<endl;return 0;
const int N=200005;
const int INF=1e9;

int32_t main() {
    LCBorz;
    int n,m,k;cin>>n>>m>>k;
    if(m<k){
        no;
    }
    vector<int> a(n),b(m);
    int total=0,ta=0,tb=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<k){
            no;
        }
        total+=a[i];
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
        ta+=b[i];
    }
    vector dp(ta+1,-INF);
    dp[0]=0;
    for(int i=0;i<m;i++){
        for(int j=ta;j>=b[i];j--){
            int tmp=min(b[i],n);
            dp[j]=max(dp[j],dp[j-b[i]]+tmp);
        }
    }
    int ans=-1;
    for(int i=total;i<=ta;i++){
        if(dp[i]>=k*n){
            ans=i;break;
        }
    }
    if(ans==-1){
        no;
    }
    else{
        cout<<ans-total<<endl;
    }

    return 0;
}

Compilation message

kitchen.cpp: In function 'int32_t main()':
kitchen.cpp:17:22: warning: unused variable 'tb' [-Wunused-variable]
   17 |     int total=0,ta=0,tb=0;
      |                      ^~
# 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 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 604 KB Output is correct
2 Correct 17 ms 604 KB Output is correct
3 Correct 18 ms 604 KB Output is correct
4 Correct 29 ms 604 KB Output is correct
5 Correct 29 ms 604 KB Output is correct
6 Correct 13 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 352 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 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 21 ms 604 KB Output is correct
15 Correct 17 ms 604 KB Output is correct
16 Correct 18 ms 604 KB Output is correct
17 Correct 29 ms 604 KB Output is correct
18 Correct 29 ms 604 KB Output is correct
19 Correct 13 ms 604 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 352 KB Output is correct
25 Correct 15 ms 604 KB Output is correct
26 Correct 19 ms 604 KB Output is correct
27 Correct 6 ms 568 KB Output is correct
28 Correct 15 ms 608 KB Output is correct
29 Correct 21 ms 604 KB Output is correct
30 Correct 35 ms 860 KB Output is correct