首页 > 其他 > 详细

1100 final standings

时间:2018-09-22 11:16:49      阅读:143      评论:0      收藏:0      [点我收藏+]

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;
}

 

1100 final standings

原文:https://www.cnblogs.com/stiles/p/timus1100.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!