Submission #928884

# Submission time Handle Problem Language Result Execution time Memory
928884 2024-02-17T07:33:27 Z Faisal_Saqib Kitchen (BOI19_kitchen) C++17
0 / 100
1 ms 348 KB
#include <iostream>
using namespace std;
#define int long long
const int N=301;
int a[N],b[N],c[N];
signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    int n,m,k;
    cin>>n>>m>>k;
    int sum1=0;
    int sum2=n*k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<k)
        {
            cout<<"Impossible"<<endl;
            exit(0);
        }
        sum1+=a[i];
    }
    int ans=-1;
    for(int j=0;j<m;j++)
    {
        cin>>b[j];
        c[j]=min(n,b[j]);
    }
    for(int mask=0;mask<(1<<m);mask++)
    {
        int r=0;
        int sum4=0;
        int sum3=0;
        for(int j=0;j<m;j++)
        {
            if(mask&(1<<j))
            {
                sum3+=b[j];
                sum4+=c[j];
            }
        }
        if(sum3>=sum1 and sum4>=sum2)
        {
            if(ans==-1)
                ans=sum3-sum4;
            else
                ans=min(ans,sum3-sum4);
        }
    }
    if(ans==-1)
        cout<<"Impossible\n";
    else
        cout<<ans<<endl;
    return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:33:13: warning: unused variable 'r' [-Wunused-variable]
   33 |         int r=0;
      |             ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -