fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int n,u,v;
  4. priority_queue <pair<int,int>> pq;
  5. int main()
  6. {
  7. cin>>n;
  8. while(n--)
  9. {
  10. cin>>u>>v;
  11. pq.push({-u,v});
  12. }
  13.  
  14. while(!pq.empty())
  15. {
  16. u=-pq.top().first; v=pq.top().second; pq.pop();
  17.  
  18. cout<<u<<" "<<v<<endl;
  19. }
  20. }
  21.  
Success #stdin #stdout 0s 16064KB
stdin
4
10 20
10 10
2 10
1 5
stdout
1 5
2 10
10 20
10 10