ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1100. Final Standings

C++ Solution using stable_sort(0.203s)
Posted by Asif Anwar Sajid 3 Apr 2021 12:19
#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define F first
#define S second
typedef long long ll;
typedef vector< int > vi;
typedef vector< ll > VI;
typedef map< int, int > mp;
typedef vector< pair< int, int > > vp;
#define debug cout << -1 << endl;
#define REP(i, a, b) for(int i=a; i<b; i++)
//#define sort(a) sort(a.begin(), a.end())
#define pop pop_back
const ll MOD = 1000000007;
const int maxN = 2001;

int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};

bool cmp(pair< int, int > a, pair< int, int > b)
{
return a.F > b.F;
}

void solve()
{
int n;
cin >> n;
vector< pair< int, int > > v;
for(int i=0; i<n; i++) {
int x, y;
cin >> x >> y;
v.pb({y, x});
}
stable_sort(v.begin(), v.end(), cmp);
for(int i=0; i<n; i++) {
cout << v[i].S << " " << v[i].F << endl;
}
return;
}

int main()
{
FastIO;
int t;
t = 1;
//cin >> t;
while(t--){
solve();
}
return 0;
}