fork(3) download
  1. #include <bits/stdc++.h>
  2. #define MAX 10000
  3. using namespace std;
  4.  
  5. bool compare(pair <int,int> p1,pair<int,int> p2){
  6. return p1.second>p2.second;
  7. }
  8.  
  9. int main() {
  10. // your code goes here
  11. int n;
  12. cin>>n;
  13. pair<int,int> v1[MAX];
  14. for(int i=0;i<n;i++){
  15. cin>>v1[i].first>>v1[i].second;
  16. }
  17. sort(v1,v1+n,compare);
  18. for(int i=0;i<n;i++){
  19. cout<<v1[i].first<<" "<<v1[i].second<<endl;
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 3476KB
stdin
4
32 34 
99 19 
12 45 
23 27 
stdout
12 45
32 34
23 27
99 19