-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy path10141.cpp
54 lines (46 loc) · 1.15 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
/*
ad-hoc
difficulty: easy
date: 17/Feb/2020
by: @brpapa
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct T {
int idx;
string name;
double compliance, price;
T() {}
};
// a < b
bool cmp(const T &a, const T &b) {
if (a.compliance != b.compliance)
return a.compliance > b.compliance;
if (a.price != b.price)
return a.price < b.price;
return a.idx < b.idx;
}
int main() {
int t = 1;
while (true) {
int R, P; cin >> R >> P >> ws; if (!R && !P) break;
vector<string> requeriments(R);
for (string &r : requeriments) getline(cin, r);
vector<T> proposals(P); int p = 0;
for (T &proposal : proposals) {
proposal.idx = p++;
getline(cin, proposal.name);
double d, rMet; cin >> d >> rMet >> ws;
proposal.price = d;
proposal.compliance = (double)rMet/R;
string trash;
for (int r = 0; r < rMet; r++) getline(cin, trash);
}
sort(proposals.begin(), proposals.end(), cmp);
if (t > 1) cout << endl;
printf("RFP #%d\n%s\n", t++, proposals[0].name.c_str());
}
return 0;
}