Advertisement
NAHID_GTC

Request for Proposal UVA - 10141

May 18th, 2022 (edited)
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.76 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll long long
  6.  
  7. struct store{
  8.     string Company;
  9.     double Price;
  10.     ll Piece;
  11. };
  12.  
  13. bool cmp(store a, store b);
  14. void setup();
  15. void solve();
  16. int main()
  17. {
  18.     setup();
  19.     solve();
  20. }
  21.  
  22. void solve()
  23. {
  24.    
  25.     ll n, p, flag = 0, piece, c = 1;
  26.     double price;
  27.     string s, name;
  28.     while(cin >> n >> p)
  29.     {
  30.         // cout << n << " " << p << endl;
  31.         if(n == 0 || p == 0)
  32.         {
  33.             break;
  34.         }
  35.         if(flag != 0)
  36.         {
  37.             cout << "\n" << endl;
  38.         }
  39.         flag = 1;
  40.  
  41.         struct store ara[p+8];
  42.  
  43.         cin.ignore();
  44.         for(ll i = 0; i < n; i++)
  45.         {
  46.             getline(cin, s);
  47.             // cout << s << endl;
  48.         }
  49.  
  50.         for(ll k = 0; k < p; k++)
  51.         {
  52.             getline(cin, name);
  53.             // cout << name << endl;
  54.             ara[k].Company = name;
  55.             cin >> price;
  56.             // cout <<fixed<< price << endl;
  57.             cin >> piece;
  58.  
  59.             ara[k].Price = price;
  60.             ara[k].Piece = piece;
  61.             cin.ignore();
  62.  
  63.             for(ll j = 0; j < piece; j++)
  64.             {
  65.                 getline(cin, s);
  66.                 // cout << s << endl;
  67.             }
  68.             // cout << name << " " << price << " " << piece << endl;
  69.             // cout << ara[k].Company << " " << ara[k].Price << " " << ara[k].Piece << endl;
  70.         }
  71.  
  72.         sort(ara, ara + p, cmp);
  73.  
  74.        
  75.         cout << "RFP #" << c++ << endl;
  76.  
  77.         cout << ara[p-1].Company;
  78.         // for(ll k = 0; k < p; k++)
  79.         // {
  80.         //  cout << ara[k].Company << " " << ara[k].Price << " " << ara[k].Piece << endl;
  81.         // }
  82.     }
  83.  
  84.     cout << endl;
  85. }
  86.  
  87. bool cmp(store a, store b)
  88. {
  89.     if(a.Piece != b.Piece) return (a.Piece < b.Piece);
  90.     if(a.Price != b.Price) return a.Price > b.Price;
  91.     return a.Company < b.Company;
  92. }
  93.  
  94. void setup()
  95. {
  96.     ios::sync_with_stdio(false);
  97.     cin.tie(NULL);
  98.     cout.tie(NULL);
  99.     #ifndef ONLINE_JUDGE
  100.     freopen("input.txt", "r", stdin);
  101.     freopen("output.txt", "w", stdout);
  102.     #else
  103.     #endif
  104. }
  105.  
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement