-
Notifications
You must be signed in to change notification settings - Fork 0
/
uva10141.cpp
76 lines (55 loc) · 1.58 KB
/
uva10141.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
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <vector>
using namespace std;
int main(){
int n, p, counter(1);
while(cin>>n>>p){
if(n == 0 && p == 0){
break;
}else{
if(counter != 1){
cout<<endl;
}
}
string requirments;
for(int i = 0; i < n; i++){
getline(cin>>ws, requirments);
}
string rfp[p];
double price[p];
double compliance[p];
for(int j = 0; j < p; j++){
getline(cin>>ws, rfp[j]);
cin>>price[j];
int met;
cin>>met;
for(int k = 0; k < met; k++){
getline(cin>>ws, requirments);
}
compliance[j] = (met * 1.0) / n;
}
vector<int> maxCompIndexes;
double maxComp = -1;
for(int l = 0; l < p; l++){
if(compliance[l] > maxComp){
maxCompIndexes.clear();
maxComp = compliance[l];
maxCompIndexes.push_back(l);
}else if(compliance[l] == maxComp){
maxCompIndexes.push_back(l);
}
}
int bestRfpIndex;
double minPrice = 1000000000000;
for(int j = 0; j < maxCompIndexes.size(); j++){
if(minPrice > price[maxCompIndexes[j]]){
minPrice = price[maxCompIndexes[j]];
bestRfpIndex = maxCompIndexes[j];
}
}
cout<<"RFP #"<<counter++<<endl;
cout<<rfp[bestRfpIndex]<<endl;
}
return 0;
}
// medium 5 solved in 36min and 56sec