-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuva-10141.cpp
More file actions
61 lines (47 loc) · 1.34 KB
/
uva-10141.cpp
File metadata and controls
61 lines (47 loc) · 1.34 KB
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
#include <bits/stdc++.h>
using namespace std;
struct proposalBrand
{
char brandName[100];
int metRequirement;
double totalPrice;
double compliance;
};
bool compare(proposalBrand x, proposalBrand y)
{
if (x.compliance == y.compliance) {
return x.totalPrice < y.totalPrice;
}
return x.compliance > y.compliance;
}
int main()
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
int n, p, i, j, testCase = 1;
char str[100];
proposalBrand *brands;
while (scanf("%d%d", &n, &p), (n && p)) {
getchar();
for (i = 1; i <= n; i++) {
gets(str);
}
brands = (proposalBrand *) malloc(p * sizeof(proposalBrand));
for (i = 0; i < p; i++) {
gets(brands[i].brandName);
scanf("%lf%d", &brands[i].totalPrice, &brands[i].metRequirement);
getchar();
brands[i].compliance = (brands[i].metRequirement * 1.0) / n;
for (j = 1; j <= brands[i].metRequirement; j++) {
gets(str);
}
}
sort(brands, brands + p, compare);
if (testCase > 1) {
printf("\n");
}
printf("RFP #%d\n%s\n", testCase++, brands[0].brandName);
free(brands);
}
return 0;
}