Submission #1016948

# Submission time Handle Problem Language Result Execution time Memory
1016948 2024-07-08T16:03:01 Z ayankarimova Kitchen (BOI19_kitchen) C++14
100 / 100
17 ms 8864 KB
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const ll sz=1e5+5, szz=1e6+5;
ll a[sz], b[sz], dp[szz], suma, sumb, f=1;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n, m, k;
    cin>>n>>m>>k;
    for(int i=1; i<szz; i++) dp[i]=-1;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        suma+=a[i];
        if(a[i]<k) f=0;
    }
    for(int i=1; i<=m; i++){
        cin>>b[i];
    }
    if(!f){ cout<<"Impossible"; return 0;}
    for(int i=1; i<=m; i++){
        sumb+=b[i];
        for(int j=sumb-b[i]; j>=0; j--){
            if(dp[j]!=-1){
                dp[j+b[i]]=max(dp[j+b[i]], dp[j]+min(n, b[i]));
            }
        }
    }
    for(int i=suma; i<sz; i++){
        if(dp[i]>=n*k){
            cout<<i-suma;
            return 0;
        }
    }
    cout<<"Impossible";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8848 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 1 ms 8856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8848 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 1 ms 8856 KB Output is correct
9 Correct 1 ms 8796 KB Output is correct
10 Correct 1 ms 8796 KB Output is correct
11 Correct 1 ms 8796 KB Output is correct
12 Correct 1 ms 8796 KB Output is correct
13 Correct 1 ms 8796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8792 KB Output is correct
2 Correct 7 ms 8796 KB Output is correct
3 Correct 6 ms 8860 KB Output is correct
4 Correct 10 ms 8796 KB Output is correct
5 Correct 17 ms 8864 KB Output is correct
6 Correct 6 ms 8656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8792 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8848 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 1 ms 8856 KB Output is correct
9 Correct 1 ms 8796 KB Output is correct
10 Correct 1 ms 8796 KB Output is correct
11 Correct 1 ms 8796 KB Output is correct
12 Correct 1 ms 8796 KB Output is correct
13 Correct 1 ms 8796 KB Output is correct
14 Correct 9 ms 8792 KB Output is correct
15 Correct 7 ms 8796 KB Output is correct
16 Correct 6 ms 8860 KB Output is correct
17 Correct 10 ms 8796 KB Output is correct
18 Correct 17 ms 8864 KB Output is correct
19 Correct 6 ms 8656 KB Output is correct
20 Correct 1 ms 8792 KB Output is correct
21 Correct 1 ms 8796 KB Output is correct
22 Correct 1 ms 8796 KB Output is correct
23 Correct 1 ms 8796 KB Output is correct
24 Correct 1 ms 8796 KB Output is correct
25 Correct 8 ms 8796 KB Output is correct
26 Correct 10 ms 8652 KB Output is correct
27 Correct 3 ms 8796 KB Output is correct
28 Correct 12 ms 8860 KB Output is correct
29 Correct 7 ms 8792 KB Output is correct
30 Correct 10 ms 8864 KB Output is correct