풀이
#include <iostream>
using namespace std;
#define MAX_W 13
int main(void) {
int N, B, H, W;
while (cin >> N >> B >> H >> W) {
int cP = 987654321;
for (int i = 0; i < H; i++) {
int P;
cin >> P;
for (int j = 0; j < W; j++) {
int w;
cin >> w;
if (w >= N && P*N <= cP) {
cP = P * N;
}
}
}
if (cP <= B) {
cout << cP << endl;
}
else {
cout << "stay home" << endl;
}
}
return 0;
}
'알고리즘 트레이닝 > UVa' 카테고리의 다른 글
441 - Lotto (0) | 2019.11.06 |
---|---|
146 - ID Codes (0) | 2019.11.04 |
573 - The Snail (0) | 2019.11.02 |
11799 - Horror Dash (0) | 2019.11.02 |
11172 - Relational Operator (0) | 2019.11.02 |