Submission #465647

# Submission time Handle Problem Language Result Execution time Memory
465647 2021-08-16T15:44:33 Z bonopo Kitchen (BOI19_kitchen) C++14
100 / 100
42 ms 716 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define rc (i<<1)|1
#define lc (i<<1)
#define el "\n"
#define f first
#define s second

typedef long long ll;
const int MM=1e5+5, MOD=1e9+7, LOG=19;
int N, M, K, dp[MM], mn=1e9, sm;

int32_t main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    cin>>N>>M>>K;
    for(int i=1, x; i<=N; ++i) {
        cin>>x, sm+=x, mn=min(mn, x); }
    memset(dp, -0x3f, sizeof(dp)); dp[0]=0;
    if(mn<K) {
        return cout<<"Impossible", 0; }
    for(int i=1, x; i<=M; ++i) {
        cin>>x;
        for(int j=MM-1; j>=x; --j) dp[j]=max(dp[j], dp[j-x]+min(x, N)); }
    for(int i=sm; i<MM; ++i) if(dp[i]>=N*K) {
        return cout<<i-sm<<el, 0; }
    cout<<"Impossible"<<el;
}

// MM
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 708 KB Output is correct
7 Correct 1 ms 700 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 708 KB Output is correct
7 Correct 1 ms 700 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 2 ms 588 KB Output is correct
11 Correct 2 ms 588 KB Output is correct
12 Correct 2 ms 588 KB Output is correct
13 Correct 2 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 588 KB Output is correct
2 Correct 25 ms 712 KB Output is correct
3 Correct 35 ms 716 KB Output is correct
4 Correct 42 ms 588 KB Output is correct
5 Correct 31 ms 588 KB Output is correct
6 Correct 23 ms 712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 588 KB Output is correct
2 Correct 5 ms 588 KB Output is correct
3 Correct 5 ms 588 KB Output is correct
4 Correct 5 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 708 KB Output is correct
7 Correct 1 ms 700 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 2 ms 588 KB Output is correct
11 Correct 2 ms 588 KB Output is correct
12 Correct 2 ms 588 KB Output is correct
13 Correct 2 ms 588 KB Output is correct
14 Correct 28 ms 588 KB Output is correct
15 Correct 25 ms 712 KB Output is correct
16 Correct 35 ms 716 KB Output is correct
17 Correct 42 ms 588 KB Output is correct
18 Correct 31 ms 588 KB Output is correct
19 Correct 23 ms 712 KB Output is correct
20 Correct 5 ms 588 KB Output is correct
21 Correct 5 ms 588 KB Output is correct
22 Correct 5 ms 588 KB Output is correct
23 Correct 5 ms 588 KB Output is correct
24 Correct 1 ms 588 KB Output is correct
25 Correct 31 ms 712 KB Output is correct
26 Correct 26 ms 588 KB Output is correct
27 Correct 18 ms 712 KB Output is correct
28 Correct 27 ms 588 KB Output is correct
29 Correct 28 ms 588 KB Output is correct
30 Correct 33 ms 588 KB Output is correct