-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11559.cpp
66 lines (39 loc) · 1.05 KB
/
11559.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <bits/stdc++.h> //
#define rows 10
#define cols 10
using namespace std;
int main(){
int N, B, H, W;
int temp;
int j;
int prices[19];
int rooms_h[19][14];
bool stop;
int min;
int i;
while(scanf("%d %d %d %d", &N, &B, &H, &W) != EOF ){
for(int i = 0; i < H; i++){
scanf("%d", &prices[i]); // P
for(j = 0; j < W; j++){
scanf("%d", &temp);
rooms_h[i][j] = temp; // a
}
}
min = INT_MAX;
for(i = 0; i < H; i++){
for(j = 0; j < W; j++){
if(rooms_h[i][j] >= N ){
break;
}
}
if(j != W){
min = min > prices[i] ? prices[i] : min;
}
}
if(min != INT_MAX && min*N <= B){
printf("%d\n", min*N);
}else{
printf("stay home\n");
}
}
}