Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define pb push_back
  5. #define eb emplace_back
  6. #define mk make_pair
  7. #define fi first
  8. #define se second
  9. #define cc(x)   cout << #x << " = " << x << endl
  10. #define ok      cout << "ok" << endl
  11. #define endl '\n'
  12.  
  13. typedef long long ll;
  14. typedef pair<int,int> ii;
  15. const int INF = 0x3f3f3f3f;
  16. const double PI = acos(-1.0);
  17.  
  18. struct node {
  19.     int id, pt, x;
  20. };
  21.  
  22. vector<node> v;
  23.  
  24. int main() {
  25.     ios_base::sync_with_stdio(false);
  26.     int n; cin >> n;
  27.     int u,z;
  28.  
  29.     for(int i = 0; i < n; i++) {
  30.         cin >> u >> z;
  31.         v.pb({u,z,i});
  32.     }
  33.  
  34.     sort(v.begin(), v.end(), [&] (const node &a, const node &b) {
  35.         if(a.pt != b.pt) return a.pt < b.pt;
  36.         return a.x > b.x;
  37.     });
  38.  
  39.     for(int i = n-1; i >= 0; i--)
  40.         cout << v[i].id << " " << v[i].pt << endl;
  41.    
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement