forked from Diusrex/UVA-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
10141 Request for Proposal.cpp
52 lines (35 loc) · 1.1 KB
/
10141 Request for Proposal.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
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
int n, p, bestMet, tempMet, t = 1;
double tempPrice, bestPrice;
string temp, best, junk, separator = "";
while (scanf("%d %d", &n, &p), n)
{
cout << separator;
separator = "\n";
bestMet = bestPrice = -1;
cin.ignore();
// Remove requirement names
for (int i = 0; i < n; ++i)
getline(cin, junk);
while (p--)
{
getline(cin, temp);
scanf("%lf %d", &tempPrice, &tempMet);
cin.ignore();
for (int i = 0; i < tempMet; ++i)
getline(cin, junk);
if (tempMet > bestMet || (tempMet == bestMet && (tempPrice < bestPrice || bestPrice == -1)))
{
best = temp;
bestPrice = tempPrice;
bestMet = tempMet;
}
}
printf("RFP #%d\n%s\n", t, best.c_str());
++t;
}
}