-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUva11559.cpp
More file actions
58 lines (50 loc) · 1.29 KB
/
Copy pathUva11559.cpp
File metadata and controls
58 lines (50 loc) · 1.29 KB
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
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <algorithm>
using namespace std;
int main()
{
int NumberOfPersons,Budget,Hotels,Weeks;
while(scanf("%d %d %d %d",&NumberOfPersons,&Budget,&Hotels,&Weeks)!=EOF){
vector<int> prices;
vector<bool> markArr;
markArr.push_back(false);
int c=0;
while(Hotels--){
int price;
vector<int> NumbofAvalBeds;
scanf("%d",&price);
int bed;
for(int i=0;i<Weeks;i++){
scanf("%d",&bed);
NumbofAvalBeds.push_back(bed);
}
for(int i=0;i<NumbofAvalBeds.size();i++){
if(NumbofAvalBeds[i]>=NumberOfPersons){
markArr[c]=true;
break;
}
}
if(markArr[c]){
int price1=NumberOfPersons * price;
if(price1<=Budget){
prices.push_back(price1);
}
}
c++;
}
if(prices.size()>0){
sort(prices.begin(),prices.end());
cout<<prices[0]<<endl;
}
else{
cout<<"stay home"<<endl;
}
}
return 0;
}