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[]; bool temp(node a, node b)
{
return a.m > b.m;
} int main(){
//freopen("input.txt","r",stdin);
int N = ;
cin >> N;
for(int i = ; 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 = ; i<N; i++)
cout << a[i].id <<" "<< a[i].m << endl;
return ;
}
1100 final standings的更多相关文章
- ural 1100. Final Standings(数据结构)
1100. Final Standings Time limit: 1.0 secondMemory limit: 16 MB Old contest software uses bubble sor ...
- 1.13抽象类及接口(附简述final关键字)
一.final final的中文意思就是不可更改的,最终的. 1.final修饰变量,那么该变量无法更改.一旦该变量赋了初值,就不能重新赋值. final MAX = 1100; //final修饰后 ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem C. Contest 水题
Problem C. Contest 题目连接: http://codeforces.com/gym/100714 Description The second round of the annual ...
- Codeforces Round #604 (Div. 2) C. Beautiful Regional Contest
链接: https://codeforces.com/contest/1265/problem/C 题意: So the Beautiful Regional Contest (BeRC) has c ...
- [C++]Yellow Cards - GYM - 102348A(Practice *) - CodeForces
1 Problem Description Problem The final match of the Berland Football Cup has been held recently. Th ...
- 继承extends、super、this、方法重写overiding、final、代码块_DAY08
1:Math类的随机数(掌握) 类名调用静态方法. 包:java.lang 类:Math 方法:public static double random(): Java.lang包下的类是不用导包就可 ...
- HDU 6651 Final Exam (思维)
2019 杭电多校 7 1006 题目链接:HDU 6651 比赛链接:2019 Multi-University Training Contest 7 Problem Description Fin ...
- java抽象、接口 和final
抽象 一.抽象类:不知道是具体什么东西的类. abstract class 类名 1.抽象类不能直接new出来. 2.抽象类可以没有抽象方法. public abstract class USB { ...
- Java内部类final语义实现
本文描述在java内部类中,经常会引用外部类的变量信息.但是这些变量信息是如何传递给内部类的,在表面上并没有相应的线索.本文从字节码层描述在内部类中是如何实现这些语义的. 本地临时变量 基本类型 fi ...
随机推荐
- 【Lua】关于遍历指定路径下所有目录及文件
关于Lua中如何遍历指定文件路径下的所有文件,需要用到Lua的lfs库. 首先创建一个temp.lua文件,用编辑器打开: 要使用lfs库,首先需要把lfs库加载进来 require("lf ...
- 【Css】一个简单的图片库
今天做一个简单的图片库! 其实这个在w3school教程里介绍得很好了,不过看到什么,自己动手做一次,记得也深刻不是. 我们分几步来走: 第一步:先写一个坯子. <html> <he ...
- unity调用ios原生代码objective-c和回调
从c#到objective-c学习 https://www.runoob.com/w3cnote/objective-c-tutorial.html https://www.jianshu.com/p ...
- CountDownLatch同步工具--控制多个线程执行顺序
好像倒计时计数器,调用CountDownLatch对象的countDown方法就将计数器减1,当到达0时,所有等待者就开始执行. java.util.concurrent.CountDownLatch ...
- Tensorflow中的数据对象Dataset
基础概念 在tensorflow的官方文档是这样介绍Dataset数据对象的: Dataset可以用来表示输入管道元素集合(张量的嵌套结构)和"逻辑计划"对这些元素的转换操作.在D ...
- cut、grep和排序命令
1.cut 对于行进行操作 cut -d ':' -f 2 以':'为分隔符,切出第二部分的所有行 cut -c 12- 从第12字符往后的字符所有行 2.grep grep '选取的串' 选出所有含 ...
- [转]Entity Framework Sprocs with Multiple Result Sets
本文转自:https://msdn.microsoft.com/en-us/data/jj691402.aspx Entity Framework Sprocs with Multiple Resul ...
- 远程桌面下启动MATLAB时的License Manager Error -103错误
之前使用学校提供的正版lincense,是通过MATLAB 官网注册下载的MATLAB 2017a,远程登录可用打开.后来学校停止购买了,时间紧迫,网上下载了一个standalone的lincense ...
- 【6】.net msmq消息队列实例
1.msmq消息队列windows环境安装 控制面板---->程序和功能---->启用或关闭Windows程序---->Microsoft Message Queue(MSMQ)服务 ...
- radio 实现点击两次 第一次点击选中第二次点击取消
由于项目的需求,要求radio点击两次后为取消状态,不方便修改为checkbox,可以用正面的方法实现. // jquery $('input:radio').click(function(){ // ...