11559 – Event Planning

By thinking 24 hr++ I have solved this problem.I got guidance from my friend M.H Riyad also..He discussed and showed me how to solve this problem easily..Thank you dost for your kindness 🙂

Here is my code it is accepted..Alhamdulillah 🙂

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int person,budget,hotel,weeks,i,j,bed,price,cost;
    int aray[10000],length;
    while(cin>>person>>budget>>hotel>>weeks)
    {
        length=0;
        for(i=1; i<=hotel; i++)
        {
            cin>>price;
            for(j=1; j<=weeks; j++)
            {
                cin>>bed;
                if(bed>=person)
                {
                    cost=person*price;
                    if(cost<=budget)
                        aray[length++]=cost;
                }

            }

        }
        if(length==0)
        {
            puts("stay home");
        }
        else
        {
            sort(aray,aray+length);
            cout<<aray[0]<<endl;
        }

    }
    return 0;
}
It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *