fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. vector<pair<int,int>> arr;
  8.  
  9. bool sortfunc(const pair<int,int> &a,const pair<int,int> &b){
  10. if(a.first < b.first){
  11. return a.first > b.first;
  12. }
  13. else if(a.first == b.first){
  14. return a.second < b.second;
  15. }
  16. }
  17.  
  18. int main(){
  19. int result = 0;
  20. int n, l ,k;
  21. cin >> n >> l >> k;
  22. for(int i = 0; i < n; i++){
  23. int sub1, sub2;
  24. cin >> sub1 >> sub2;
  25. arr.push_back(make_pair(sub1,sub2));
  26. }
  27. sort(arr.begin(),arr.end(),sortfunc);
  28. for(int i = 0; i < n ; i++){
  29. cout << arr[i].first <<' ' << arr[i].second << endl;
  30. }
  31. }
Success #stdin #stdout 0s 15240KB
stdin
8 7 5
1 3
2 4
3 6
4 8
5 8
6 9
6 7
7 10
stdout
1 3
2 4
3 6
4 8
5 8
6 7
6 9
7 10