1100 final standings

http://acm.timus.ru/problem.aspx?space=1&num=1100 link to the problem

make a fast stable sorting algorithm. 

what is sort in c, quick sort.

what is a stable sort?

a sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input array to be sorted.

#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

struct node
{
  int id;
  int m;
}a[150005];

bool temp(node a, node b)
{
  return a.m > b.m;
}

int main(){
  //freopen("input.txt","r",stdin);
  int N = 0;
  cin >> N;
  for(int i = 0; i<N; i++)
    cin >>a[i].id >> a[i].m;
  stable_sort(a, a+N, temp);//using stable sort here instead od quick sort
  for(int i = 0; i<N; i++)
    cout << a[i].id <<" "<< a[i].m << endl;
  return 0;
}

 

posted @ 2018-09-22 04:18  wz30  阅读(116)  评论(0编辑  收藏  举报