-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10141.cpp
63 lines (59 loc) · 1.31 KB
/
10141.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
#include "bits/stdc++.h"
//#include <bits/stdc++.h>
// NOT DONE
using namespace std;
int main () {
int n, p;
int k = 1;
while (scanf("%d %d", &n,&p) != EOF) {
if (n == 0 && p == 0) break;
string nameAns;
double priceAns;
double complience = -1.0;
double number_of_requirements = double (n);
set<string> req;
cin.ignore();
while (n--) {
string str;
getline(cin,str);
req.insert(str);
}
//cin.ignore();
while (p--) {
int reqMet = 0;
string name;
double price;
int numReq;
getline(cin,name);
cin >> price >> numReq;
//scanf("%lf %d",&price, &numReq);
cin.ignore();
while (numReq--) {
string newReq;
cin.ignore();
getline(cin,newReq);
set<string>::iterator it;
it = req.find(newReq);
if (it != req.end()) {
++reqMet;
}
}
double thisComp = reqMet / number_of_requirements;
if (thisComp > complience) {
complience = thisComp;
priceAns = price;
nameAns = name;
}
if (thisComp == complience) {
if (price < priceAns) {
complience = thisComp;
priceAns = price;
nameAns = name;
}
}
}
printf("RFP #%d\n",k);
cout << nameAns << endl;
k++;
}
}