|
|
вернуться в форумi don't think it gets wa, however... // 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; } |
|
|