Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define cin(v) \
- for (auto &i : v) \
- cin >> i;
- #define cout(v) \
- for (auto &i : v) \
- cout << i << " ";
- #define br cout << '\n';
- #define ll long long
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- void Warding()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- bool is_prime(int n)
- {
- if (n <= 1)
- return false;
- for (int i = 2; i <= sqrt(n); i++)
- if (n % i == 0)
- return false;
- return true;
- }
- bool comp(pair<double, string> &a, pair<double, string> &b)
- {
- if (a.first == b.first)
- return a.second < b.second;
- else
- return a.first > b.first;
- }
- void solve()
- {
- int n, holder = 0;
- cin >> n;
- vector<pair<string, pair<pair<double, double>, double>>> v(n);
- vector<pair<double, string>> ans(n);
- for (int i = 0; i < n; i++)
- {
- cin >> v[i].first >> v[i].second.first.first >> v[i].second.second >> v[i].second.first.second;
- }
- for (int i = 0; i < n; i++)
- {
- ans[i].first = double(v[i].second.first.first + (v[i].second.first.second * 5 / 10) - (v[i].second.second * 75 / 100));
- ans[i].second = v[i].first;
- }
- sort(all(ans), comp);
- cout << ans[0].second << " " << holder << endl;
- for (int i = 1; i < n; i++)
- {
- if (ans[i].first == ans[i - 1].first)
- {
- if (ans[i].second > ans[i - 1].second)
- cout << ans[i].second << " " << holder << endl;
- else
- cout << ans[i - 1].second << " " << holder << endl;
- }
- else
- cout << ans[i].second << " " << i << endl, holder = i;
- }
- }
- int main()
- {
- Warding();
- int t = 1;
- cin >> t;
- while (t--)
- {
- solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment