Submission #1048096

# Submission time Handle Problem Language Result Execution time Memory
1048096 2024-08-07T22:30:07 Z Braabebo10 Kitchen (BOI19_kitchen) C++17
100 / 100
11 ms 8288 KB
#include <bits/stdc++.h>
#define ll long long
#define nl "\n"
#define yes "YES"
#define no "NO"
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const ll N=1e6+10;
ll n,m,k;
vector<ll>a,b;
ll dp[N];
int main() {
    fast
    memset(dp,-1, sizeof(dp));
    cin>>n>>m>>k;
    a=vector<ll>(n);
    b=vector<ll>(m);
    ll sm=0;
    bool ok=1;
    for(ll &i:a)cin>>i,sm+=i,ok&=(i>=k);
    for(ll &i:b)cin>>i;
    if(!ok){
        cout<<"Impossible"<<nl;
        return 0;
    }
    ll sm2=0;
    dp[0]=0;
    for(ll i=1;i<=m;i++){
        for(ll j=sm2;j>=0;j--){
            if(dp[j]!=-1)dp[j+b[i-1]]=max(dp[j+b[i-1]],dp[j]+min(n,b[i-1]));
        }
        sm2+=b[i-1];
    }
    for(ll i=sm;i<N;i++){
        if(dp[i]>=n*k){
            cout<<i-sm<<nl;
            return 0;
        }
    }
    cout<<"Impossible"<<nl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8280 KB Output is correct
2 Correct 1 ms 8028 KB Output is correct
3 Correct 1 ms 8028 KB Output is correct
4 Correct 1 ms 8068 KB Output is correct
5 Correct 1 ms 8284 KB Output is correct
6 Correct 1 ms 8028 KB Output is correct
7 Correct 1 ms 8028 KB Output is correct
8 Correct 2 ms 8028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8280 KB Output is correct
2 Correct 1 ms 8028 KB Output is correct
3 Correct 1 ms 8028 KB Output is correct
4 Correct 1 ms 8068 KB Output is correct
5 Correct 1 ms 8284 KB Output is correct
6 Correct 1 ms 8028 KB Output is correct
7 Correct 1 ms 8028 KB Output is correct
8 Correct 2 ms 8028 KB Output is correct
9 Correct 2 ms 8284 KB Output is correct
10 Correct 2 ms 8024 KB Output is correct
11 Correct 2 ms 8280 KB Output is correct
12 Correct 1 ms 8028 KB Output is correct
13 Correct 2 ms 8280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8280 KB Output is correct
2 Correct 6 ms 8284 KB Output is correct
3 Correct 6 ms 8284 KB Output is correct
4 Correct 11 ms 8284 KB Output is correct
5 Correct 10 ms 8288 KB Output is correct
6 Correct 7 ms 8280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8084 KB Output is correct
2 Correct 1 ms 8028 KB Output is correct
3 Correct 1 ms 8028 KB Output is correct
4 Correct 1 ms 8028 KB Output is correct
5 Correct 1 ms 8284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8280 KB Output is correct
2 Correct 1 ms 8028 KB Output is correct
3 Correct 1 ms 8028 KB Output is correct
4 Correct 1 ms 8068 KB Output is correct
5 Correct 1 ms 8284 KB Output is correct
6 Correct 1 ms 8028 KB Output is correct
7 Correct 1 ms 8028 KB Output is correct
8 Correct 2 ms 8028 KB Output is correct
9 Correct 2 ms 8284 KB Output is correct
10 Correct 2 ms 8024 KB Output is correct
11 Correct 2 ms 8280 KB Output is correct
12 Correct 1 ms 8028 KB Output is correct
13 Correct 2 ms 8280 KB Output is correct
14 Correct 7 ms 8280 KB Output is correct
15 Correct 6 ms 8284 KB Output is correct
16 Correct 6 ms 8284 KB Output is correct
17 Correct 11 ms 8284 KB Output is correct
18 Correct 10 ms 8288 KB Output is correct
19 Correct 7 ms 8280 KB Output is correct
20 Correct 2 ms 8084 KB Output is correct
21 Correct 1 ms 8028 KB Output is correct
22 Correct 1 ms 8028 KB Output is correct
23 Correct 1 ms 8028 KB Output is correct
24 Correct 1 ms 8284 KB Output is correct
25 Correct 5 ms 8284 KB Output is correct
26 Correct 7 ms 8284 KB Output is correct
27 Correct 3 ms 8284 KB Output is correct
28 Correct 7 ms 8284 KB Output is correct
29 Correct 7 ms 8288 KB Output is correct
30 Correct 10 ms 8284 KB Output is correct