#include<bits/stdc++.h>
#define x long long int
using namespace std;
int main()
{
x N, B, H, W, p, i, j, m, c, k;
while(cin >> N >> B >> H >> W)
{
int a[W];
k = j = p = 0;
m = 5000000;
while(j < H)
{
c = 0;
cin >> p;
for(i=0; i<W; i++)
{
cin >> a[i];
if(a[i] >= N)
{
c++;
}
}
if(c>0)
{
if(m > (p*N) && (p*N) <= B)
m = p*N;
}
j++;
}
if(m == 5000000)
cout << "stay home" << endl;
else
cout << m << endl;
}
return 0;
}
#define x long long int
using namespace std;
int main()
{
x N, B, H, W, p, i, j, m, c, k;
while(cin >> N >> B >> H >> W)
{
int a[W];
k = j = p = 0;
m = 5000000;
while(j < H)
{
c = 0;
cin >> p;
for(i=0; i<W; i++)
{
cin >> a[i];
if(a[i] >= N)
{
c++;
}
}
if(c>0)
{
if(m > (p*N) && (p*N) <= B)
m = p*N;
}
j++;
}
if(m == 5000000)
cout << "stay home" << endl;
else
cout << m << endl;
}
return 0;
}
Comments
Post a Comment