IMohammedNasr

Untitled

Apr 6th, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. bool comp(pair<double, string> &a, pair<double, string> &b)
  2. {
  3. if (a.first == b.first)
  4. return a.second < b.second;
  5. else
  6. return a.first > b.first;
  7. }
  8.  
  9. void solve()
  10. {
  11. int n, holder = 0;
  12. double k, d, a;
  13. string s;
  14. cin >> n;
  15. vector<pair<double, string>> v(n);
  16. while (n--)
  17. {
  18. cin >> s >> k >> d >> a;
  19. v[n].first = k + (a * 1 / 2) - (d * 3 / 4);
  20. v[n].second = s;
  21. }
  22. sort(all(v), comp);
  23. cout << v[0].second << " " << holder << endl;
  24. for (int i = 1; i < v.size(); i++)
  25. {
  26. if (v[i].first == v[i - 1].first)
  27. {
  28. cout << v[i].second << " " << holder << endl;
  29. }
  30. else
  31. cout << v[i].second << " " << i << endl, holder = i;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment