Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- struct store{
- string Company;
- double Price;
- ll Piece;
- };
- bool cmp(store a, store b);
- void setup();
- void solve();
- int main()
- {
- setup();
- solve();
- }
- void solve()
- {
- ll n, p, flag = 0, piece, c = 1;
- double price;
- string s, name;
- while(cin >> n >> p)
- {
- // cout << n << " " << p << endl;
- if(n == 0 || p == 0)
- {
- break;
- }
- if(flag != 0)
- {
- cout << "\n" << endl;
- }
- flag = 1;
- struct store ara[p+8];
- cin.ignore();
- for(ll i = 0; i < n; i++)
- {
- getline(cin, s);
- // cout << s << endl;
- }
- for(ll k = 0; k < p; k++)
- {
- getline(cin, name);
- // cout << name << endl;
- ara[k].Company = name;
- cin >> price;
- // cout <<fixed<< price << endl;
- cin >> piece;
- ara[k].Price = price;
- ara[k].Piece = piece;
- cin.ignore();
- for(ll j = 0; j < piece; j++)
- {
- getline(cin, s);
- // cout << s << endl;
- }
- // cout << name << " " << price << " " << piece << endl;
- // cout << ara[k].Company << " " << ara[k].Price << " " << ara[k].Piece << endl;
- }
- sort(ara, ara + p, cmp);
- cout << "RFP #" << c++ << endl;
- cout << ara[p-1].Company;
- // for(ll k = 0; k < p; k++)
- // {
- // cout << ara[k].Company << " " << ara[k].Price << " " << ara[k].Piece << endl;
- // }
- }
- cout << endl;
- }
- bool cmp(store a, store b)
- {
- if(a.Piece != b.Piece) return (a.Piece < b.Piece);
- if(a.Price != b.Price) return a.Price > b.Price;
- return a.Company < b.Company;
- }
- void setup()
- {
- ios::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #else
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement