Timus : 1100 (Final Standings)



// http://acm.timus.ru/problem.aspx?space=1&num=1100
// Tag: Stable sort 

#include <cstdio>
#include <algorithm>

using namespace std;

struct node {
    int id;
    int solve;
} a [10000000 + 10];

bool cmp (node p, node q)
{
    if ( p.solve > q.solve ) return true;
    return false;
}

int main ()
{
    int n; scanf ("%d", &n);

    for ( int i = 0; i < n; i++ ) scanf ("%d %d", &a [i].id, &a [i].solve);

    stable_sort (a, a + n, cmp);

    for ( int i = 0; i < n; i++ ) printf ("%d %d\n", a [i].id, a [i].solve);

    return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s