Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. struct teams {
  9.     string name;
  10.     int s;
  11.     int p;
  12. };
  13.  
  14. bool compare(teams lhs, teams rhs) {
  15.     if (lhs.s != rhs.s) {
  16.         return lhs.s > rhs.s;
  17.     }
  18.     else if (lhs.p != rhs.s) {
  19.         return lhs.p < rhs.p;
  20.     }
  21.     else if (lhs.name != rhs.name) {
  22.         return lhs.name < rhs.name;
  23.     }
  24. }
  25.  
  26.  int main() {
  27.     int n, i;
  28.     cin >> n;
  29.     vector <teams> t(n);
  30.     for (i = 0; i < n; i++) {
  31.         cin >> t[i].name >> t[i].s >> t[i].p;
  32.     }
  33.     sort(t.begin(), t.end(), compare);
  34.     for (i = 0; i < n; i++) {
  35.         cout << t[i].name << endl;
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement