-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa-11559.cpp
More file actions
45 lines (32 loc) · 840 Bytes
/
UVa-11559.cpp
File metadata and controls
45 lines (32 loc) · 840 Bytes
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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N, B, H, W;
// N: number of people
// B: budget
// H: number of hotels
// W: number of weeks
while (cin >> N >> B >> H >> W) {
int mini = B+1;
for (int i = 0; i < H; i++) {
int unit_cost; // p
cin >> unit_cost;
for (int i = 0; i < W; i++) {
int bed; // a
cin >> bed;
int tot = N*unit_cost; // p*N
if (bed >= N && tot <= mini) {
mini = tot;
}
}
}
if (mini <= B) {
cout << mini << endl;
}
else
cout << "stay home" << endl;
}
return 0;
}