Submission #207089

# Submission time Handle Problem Language Result Execution time Memory
207089 2020-03-06T11:19:18 Z brcode Kitchen (BOI19_kitchen) C++14
100 / 100
167 ms 104056 KB
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
const int MAXN = 310;
const int MAXN2 = 310*310;

int a[MAXN];
int b[MAXN];
int dp[MAXN2][MAXN];
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    int holdsum = 0;
    int holdsum2 = 0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        holdsum+=a[i];
        if(a[i]<k){
            cout<<"Impossible"<<endl;
            return 0;
        }
    }
    for(int i=1;i<=m;i++){
        cin>>b[i];
        holdsum2 += b[i];
    }
    for(int i=0;i<=holdsum2;i++){
        for(int j=0;j<=m;j++){
            dp[i][j] = -1e9;
        }
    }
    dp[0][0]= 0;
    for(int i=0;i<=holdsum2;i++){
        for(int j=1;j<=m;j++){
            dp[i][j] = dp[i][j-1];
            if(i-b[j]>=0){
                
                dp[i][j] = max(dp[i][j-1],dp[i-b[j]][j-1]+min(b[j],n));
            }
        }
    }
    for(int i=holdsum;i<=holdsum2;i++){
        for(int j=1;j<=m;j++){
            if(dp[i][j]>=n*k){
                //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
                cout<<i-holdsum<<endl;
                return 0;
            }
        }
    }
    cout<<"Impossible"<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 632 KB Output is correct
2 Correct 5 ms 636 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
4 Correct 5 ms 888 KB Output is correct
5 Correct 5 ms 1016 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 632 KB Output is correct
2 Correct 5 ms 636 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
4 Correct 5 ms 888 KB Output is correct
5 Correct 5 ms 1016 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 632 KB Output is correct
9 Correct 6 ms 4088 KB Output is correct
10 Correct 6 ms 3704 KB Output is correct
11 Correct 5 ms 632 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 7 ms 5112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 118 ms 80248 KB Output is correct
2 Correct 94 ms 69240 KB Output is correct
3 Correct 101 ms 58616 KB Output is correct
4 Correct 163 ms 100600 KB Output is correct
5 Correct 166 ms 104056 KB Output is correct
6 Correct 83 ms 61048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1912 KB Output is correct
2 Correct 5 ms 1400 KB Output is correct
3 Correct 5 ms 1784 KB Output is correct
4 Correct 6 ms 2168 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 632 KB Output is correct
2 Correct 5 ms 636 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
4 Correct 5 ms 888 KB Output is correct
5 Correct 5 ms 1016 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 632 KB Output is correct
9 Correct 6 ms 4088 KB Output is correct
10 Correct 6 ms 3704 KB Output is correct
11 Correct 5 ms 632 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 7 ms 5112 KB Output is correct
14 Correct 118 ms 80248 KB Output is correct
15 Correct 94 ms 69240 KB Output is correct
16 Correct 101 ms 58616 KB Output is correct
17 Correct 163 ms 100600 KB Output is correct
18 Correct 166 ms 104056 KB Output is correct
19 Correct 83 ms 61048 KB Output is correct
20 Correct 6 ms 1912 KB Output is correct
21 Correct 5 ms 1400 KB Output is correct
22 Correct 5 ms 1784 KB Output is correct
23 Correct 6 ms 2168 KB Output is correct
24 Correct 5 ms 256 KB Output is correct
25 Correct 96 ms 72824 KB Output is correct
26 Correct 110 ms 78072 KB Output is correct
27 Correct 44 ms 35068 KB Output is correct
28 Correct 97 ms 63736 KB Output is correct
29 Correct 124 ms 85368 KB Output is correct
30 Correct 167 ms 102264 KB Output is correct