Submission #216129

# Submission time Handle Problem Language Result Execution time Memory
216129 2020-03-26T18:26:00 Z MKopchev Kitchen (BOI19_kitchen) C++14
0 / 100
15 ms 512 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=3e2+42,inf=1e9;

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

int take_min(int a,int b)
{
    if(a==-1)return b;
    return min(a,b);
}
int filled[nmax*nmax];

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;
    }

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

        for(int bought=total;bought>=chef;bought--)
        {
            int can_buy=min(n,bought);
            filled[bought]=max(filled[bought],filled[bought-chef]+can_buy);
        }
    }

    if(total<sum)no();

    for(int i=sum;i<=total;i++)
        if(filled[i]>=k*n)ret=take_min(ret,i-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:35: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 5 ms 384 KB Output is correct
3 Incorrect 4 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 4 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 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 5 ms 384 KB Output is correct
3 Incorrect 4 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -