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