#include<stdio.h>
int main()
{
long int n,h,w,p,ary[9000],sum,minsum,count;
long int i,j,flag,k1,k2,sum1,f,b,k;
long int bed;
// freopen("F:\\a.txt","r",stdin);
while(scanf("%ld%ld%ld%ld",&n,&b,&h,&w)==4)
{
sum=b+1;
for(i=1;i<=h;i++)
{
scanf("%ld",&p);
for(k=1;k<=w;k++)
{
scanf("%ld",&bed);
if(bed>=n)
{
if(sum>n*p)
sum=n*p;
}
}
}
if(sum<b)
printf("%ld\n",sum);
else
printf("stay home\n");
}
return 0;
}
int main()
{
long int n,h,w,p,ary[9000],sum,minsum,count;
long int i,j,flag,k1,k2,sum1,f,b,k;
long int bed;
// freopen("F:\\a.txt","r",stdin);
while(scanf("%ld%ld%ld%ld",&n,&b,&h,&w)==4)
{
sum=b+1;
for(i=1;i<=h;i++)
{
scanf("%ld",&p);
for(k=1;k<=w;k++)
{
scanf("%ld",&bed);
if(bed>=n)
{
if(sum>n*p)
sum=n*p;
}
}
}
if(sum<b)
printf("%ld\n",sum);
else
printf("stay home\n");
}
return 0;
}
No comments:
Post a Comment