Submission #216111

# Submission time Handle Problem Language Result Execution time Memory
216111 2020-03-26T18:00:13 Z MKopchev Kitchen (BOI19_kitchen) C++14
9 / 100
1000 ms 10108 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=3e2+42;

void no()
{
    printf("Impossible");
    exit(0);
}

int take_min(int a,int b)
{
    if(a==-1)return b;
    return min(a,b);
}
bool can[nmax*nmax][nmax];//sum, chefs

int n,m,k;

int main()
{
    scanf("%i%i%i",&n,&m,&k);

    int sum=0,dish;
    for(int i=1;i<=n;i++)
    {
        scanf("%i",&dish);
        if(dish<k)no();
        sum=sum+dish;
    }

    can[0][0]=1;

    int chef,ret=-1,total=0;
    for(int i=1;i<=m;i++)
    {
        scanf("%i",&chef);
        total=total+chef;

        for(int j=total;j>=0;j--)
            for(int p=i;p>=1;p--)
                if(j>=chef&&can[j-chef][p-1])can[j][p]=1;
    }

    for(int j=total;j>=sum;j--)
        for(int p=m;p>=k;p--)
            if(can[j][p])ret=take_min(ret,j-sum);

    if(ret==-1)no();
    printf("%i\n",ret);
    return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i%i",&n,&m,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~
kitchen.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i",&dish);
         ~~~~~^~~~~~~~~~~~
kitchen.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i",&chef);
         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 6 ms 1280 KB Output is correct
10 Correct 5 ms 640 KB Output is correct
11 Incorrect 5 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 10108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 6 ms 1280 KB Output is correct
10 Correct 5 ms 640 KB Output is correct
11 Incorrect 5 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -