Advertisement
juanjo12x

UVA_10141_Request_For_Proposal

Jul 12th, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include<cstdio>
  2. #include<iostream>
  3.  
  4. using namespace std;
  5.  
  6. int n, p, r;
  7. float d, best_compliance, best_cost;
  8. string line, name, best_name;
  9.  
  10. int main() {
  11.     for(int T = 1;; T++) {
  12.         scanf("%d %d\n", &n, &p);
  13.         if(n == 0 && p == 0) break;
  14.         if(T > 1) cout << endl;
  15.         for(int i = 0; i < n; i++)
  16.             getline(cin, line);
  17.         best_compliance = 0.0;
  18.         best_cost = 1E37;
  19.         for(int i = 0; i < p; i++) {
  20.             getline(cin, name);
  21.             scanf("%f %d\n", &d, &r);
  22.             for(int i = 0; i < r; i++)
  23.                 getline(cin, line);
  24.             if((float) r / p > best_compliance \
  25.                     || (float) r / p == best_compliance && d < best_cost) {
  26.                 best_compliance = (float) r / p;
  27.                 best_cost = d;
  28.                 best_name = name;
  29.             }
  30.         }
  31.         cout << "RFP #" << T << endl;
  32.         cout << best_name << endl;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement