IMohammedNasr

Untitled

Apr 6th, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define cin(v) \
  4. for (auto &i : v) \
  5. cin >> i;
  6. #define cout(v) \
  7. for (auto &i : v) \
  8. cout << i << " ";
  9. #define br cout << '\n';
  10. #define ll long long
  11. #define all(v) v.begin(), v.end()
  12. #define rall(v) v.rbegin(), v.rend()
  13.  
  14. void Warding()
  15. {
  16. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  17. #ifndef ONLINE_JUDGE
  18. freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  19. #endif
  20. }
  21. bool is_prime(int n)
  22. {
  23. if (n <= 1)
  24. return false;
  25. for (int i = 2; i <= sqrt(n); i++)
  26. if (n % i == 0)
  27. return false;
  28. return true;
  29. }
  30.  
  31. bool comp(pair<double, string> &a, pair<double, string> &b)
  32. {
  33. if (a.first == b.first)
  34. return a.second < b.second;
  35. else
  36. return a.first > b.first;
  37. }
  38.  
  39. void solve()
  40. {
  41. int n, holder = 0;
  42. cin >> n;
  43. vector<pair<string, pair<pair<double, double>, double>>> v(n);
  44. vector<pair<double, string>> ans(n);
  45. for (int i = 0; i < n; i++)
  46. {
  47. cin >> v[i].first >> v[i].second.first.first >> v[i].second.second >> v[i].second.first.second;
  48. }
  49. for (int i = 0; i < n; i++)
  50. {
  51. ans[i].first = double(v[i].second.first.first + (v[i].second.first.second * 5 / 10) - (v[i].second.second * 75 / 100));
  52. ans[i].second = v[i].first;
  53. }
  54. sort(all(ans), comp);
  55. cout << ans[0].second << " " << holder << endl;
  56. for (int i = 1; i < n; i++)
  57. {
  58. if (ans[i].first == ans[i - 1].first)
  59. {
  60. if (ans[i].second > ans[i - 1].second)
  61. cout << ans[i].second << " " << holder << endl;
  62. else
  63. cout << ans[i - 1].second << " " << holder << endl;
  64. }
  65. else
  66. cout << ans[i].second << " " << i << endl, holder = i;
  67. }
  68. }
  69.  
  70. int main()
  71. {
  72. Warding();
  73. int t = 1;
  74. cin >> t;
  75. while (t--)
  76. {
  77. solve();
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment