Submission #535597

# Submission time Handle Problem Language Result Execution time Memory
535597 2022-03-10T16:12:42 Z __Variatto Kitchen (BOI19_kitchen) C++17
100 / 100
31 ms 680 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ll long long
const int MAX=9e4+10;
int n, m, k, dp[MAX], a, b, suma;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin>>n>>m>>k;
    for(int i=1; i<=n; i++){
        cin>>a;
        if(a<k){
            cout<<"Impossible\n";
            return 0;
        }
        suma+=a;
    }
    int mini=MAX;
    for(int i=1; i<=MAX-2; i++)
        dp[i]=-1;
    for(int i=1; i<=m; i++){
        cin>>b;
        for(int j=MAX-2; j>=b; j--){
            if(dp[j-b]!=-1){
                dp[j]=max(dp[j], dp[j-b]+min(n, b));
                if(j>=suma && dp[j]>=n*k)
                    mini=min(mini, j);
            }
        }
    }
    if(mini==MAX)
        cout<<"Impossible\n";
    else
        cout<<mini-suma<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 664 KB Output is correct
2 Correct 18 ms 672 KB Output is correct
3 Correct 31 ms 596 KB Output is correct
4 Correct 31 ms 596 KB Output is correct
5 Correct 25 ms 676 KB Output is correct
6 Correct 18 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 596 KB Output is correct
2 Correct 4 ms 672 KB Output is correct
3 Correct 4 ms 680 KB Output is correct
4 Correct 4 ms 596 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 26 ms 664 KB Output is correct
15 Correct 18 ms 672 KB Output is correct
16 Correct 31 ms 596 KB Output is correct
17 Correct 31 ms 596 KB Output is correct
18 Correct 25 ms 676 KB Output is correct
19 Correct 18 ms 596 KB Output is correct
20 Correct 4 ms 596 KB Output is correct
21 Correct 4 ms 672 KB Output is correct
22 Correct 4 ms 680 KB Output is correct
23 Correct 4 ms 596 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 16 ms 596 KB Output is correct
26 Correct 25 ms 668 KB Output is correct
27 Correct 17 ms 596 KB Output is correct
28 Correct 22 ms 660 KB Output is correct
29 Correct 24 ms 596 KB Output is correct
30 Correct 28 ms 596 KB Output is correct