ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1100. Final Standings

i don't think it gets wa, however...
Posted by superguo 30 Jul 2006 13:14
// 45593UU
#include<iostream>
#include<stdlib.h>
using namespace std;

long N;
struct TEAM
{
    long ID, M;
}teams[150001];

int comp(const void* a, const void* b)
{
    static TEAM *p, *q;
    p = (TEAM*)a;
    q = (TEAM*)b;
    if (p->M != q->M) return q->M < p->M ? -1 : 1;
    else return p < q ? -1 : 1;
}

void readdata()
{
    cin>>N;
    for (long i=0; i<N; i++)
            cin>>teams[i].ID>>teams[i].M;
}

void solve()
{
    qsort(teams, N, sizeof(TEAM), comp);
    for (long i=0; i<N; i++)
        cout<<teams[i].ID<<' '<<teams[i].M<<endl;
}

int main()
{
    readdata();
    solve();
    return 0;
}