Advertisement
artemgf

Таблица результатов.

Mar 15th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string>
  4. #include <math.h>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. struct team
  10. {
  11.     long long int ID, M, n;
  12. };
  13.  
  14. bool m(team p1, team p2)
  15. {
  16.     if (p1.M == p2.M)
  17.         return p1.n > p2.n;
  18.     else
  19.         return p1.M < p2.M;
  20. }
  21.  
  22. team grop[150000];
  23.  
  24. int main()
  25. {
  26.     int i, N;
  27.  
  28.     cin >> N;
  29.  
  30.     for (i = 0; i < N; i++)
  31.     {
  32.         cin >> grop[i].ID >> grop[i].M;
  33.         grop[i].n = i;
  34.     }
  35.  
  36.     sort(grop, grop + N, m);
  37.  
  38.     for (i = N-1; i >= 0; i--)
  39.         cout << grop[i].ID << " " << grop[i].M << endl;
  40.    
  41.     _getch();
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement