Advertisement
MiinaMagdy

10141 - Request for Proposal

Sep 3rd, 2022
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll long long
  6. #define endl '\n'
  7. #define sz(x) int(x.size())
  8. #define all(x) x.begin(), x.end()
  9.  
  10. int main() {
  11.     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  12.     int n, p;
  13.     int No = 0;
  14.     while (scanf("%d %d%*c", &n, &p), n || p) {
  15.         if (No) printf("\n");
  16.         while (n--) {
  17.             scanf("%*[^\n]%*c");
  18.         }
  19.         char tmp[100];
  20.         double price;
  21.         int mets;
  22.         char ans[100];
  23.         int Max_mets = 0;
  24.         double Min_price = 1e9;
  25.         for (int i = 0; i < p; i++) {
  26.             scanf("%[^\n]\n%lf%d%*c", tmp, &price, &mets);
  27.             if (mets > Max_mets || (mets == Max_mets && price < Min_price)) {
  28.                 strcpy(ans, tmp);
  29.                 Max_mets = mets;
  30.                 Min_price = price;
  31.             }
  32.             while (mets--) scanf("%*[^\n]%*c");
  33.         }
  34.         printf("RFP #%d\n%s\n", ++No, ans);
  35.     }
  36. }
  37.  
Tags: UVA CP3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement