#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
int person, budget, hotel, week, price_each_person, avail_bed, l, mn, ans;
while(cin >> person >> budget >> hotel >> week){
mn = 214748364;
while(hotel--){
cin >> price_each_person;
for(int i = 0; i < week; i++){
cin >> avail_bed;
if(avail_bed >= person){
ans = price_each_person * person;
mn = min(mn, ans);
}
}
}
if(mn <= budget)cout << mn << endl;
else cout << "stay home" << endl;
}
return 0;
}
#include <algorithm>
#include <vector>
using namespace std;
int main(){
int person, budget, hotel, week, price_each_person, avail_bed, l, mn, ans;
while(cin >> person >> budget >> hotel >> week){
mn = 214748364;
while(hotel--){
cin >> price_each_person;
for(int i = 0; i < week; i++){
cin >> avail_bed;
if(avail_bed >= person){
ans = price_each_person * person;
mn = min(mn, ans);
}
}
}
if(mn <= budget)cout << mn << endl;
else cout << "stay home" << endl;
}
return 0;
}
No comments:
Post a Comment