Mahmoud_Hawara

Untitled

Jul 19th, 2022
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  4. const long long MOD = 1e9 + 7, OO = 1e18;
  5. const double PI = acos(-1);
  6. const int N = 1e6 + 5;
  7. const int dx[4] = {0, 0, 1, -1};
  8. const int dy[4] = {1, -1, 0, 0};
  9.  
  10.  
  11. struct h {
  12.     string name;
  13.     long long a, v, s;
  14. };
  15.  
  16. bool cmp(h hero1, h hero2)
  17. {
  18.     if (hero1.a > hero2.a)return 1;
  19.     if (hero1.a < hero2.a)return 0;
  20.     if (hero1.v > hero2.v)return 1;
  21.     if (hero1.v < hero2.v)return 0;
  22.     if (hero1.s < hero2.s)return 1;
  23.     if (hero1.s > hero2.s)return 0;
  24.     return hero1.name < hero2.name;
  25. }
  26.  
  27. /*
  28.     hero1 hero2
  29.     => hero2 hero1
  30. */
  31.  
  32. long long n;
  33. h hero[N];
  34.  
  35. int main()
  36. {
  37.     IO
  38.     cin >> n;
  39.     for (int i = 1; i <= n; i++)
  40.     {
  41.         cin >> hero[i].name >> hero[i].a >> hero[i].v >> hero[i].s;
  42.     }
  43.     sort(hero + 1, hero + n + 1, cmp);
  44.     for (int i = 1; i <= n; i++)
  45.     {
  46.         cout << hero[i].name << '\n';
  47.     }
  48.     return 0;
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment