-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy path10141.cpp
executable file
·60 lines (49 loc) · 1.34 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
/* Problem: Request for Proposal UVa 10141
Programmer: Md. Mahmud Ahsan
Description: AD HOC
Compiled: Visual C++ 7.0
Date: 31-08-05
*/
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main(){
//freopen("output.txt", "w", stdout);
int n, p, i, j, cases = 0, prio, prevPrio;
double value, prevValue;
char str[500], name[500];
char final[500];
bool flag = false;
while (cin >> n >> p){
if (n == 0 && p == 0) break;
cin.getline(str, sizeof(str));// eat blank char
for (i = 0; i < n; ++i)
cin.getline(str, sizeof(str)); // ignore this
cin.getline(final, sizeof(final));
cin.getline(str, sizeof(str));
sscanf(str, "%lf%d", &prevValue,&prevPrio);
for (j = 0; j < prevPrio; ++j) cin.getline(str, sizeof(str));
for (i = 1; i < p; ++i){
cin.getline(name, sizeof(name));
cin.getline(str, sizeof(str));
sscanf(str, "%lf%d", &value,&prio);
for (j = 0; j < prio; ++j) cin.getline(str, sizeof(str));
if (prio > prevPrio){
prevPrio = prio;
strcpy(final, name);
}
else if (prio == prevPrio){
if (value < prevValue){
prevValue = value;
strcpy(final, name);
}
}
}
if (flag) cout << endl;
flag = true;
cout << "RFP #" << ++cases << endl;
cout << final << endl;
}
return 0;
}