Ural 1100. Final Standings 桶排序
来源:互联网 发布:java数据源是什么 编辑:程序博客网 时间:2024/06/08 13:39
1100. Final Standings
Time limit: 1.0 second
Memory limit: 16 MB
Memory limit: 16 MB
Old contest software uses bubble sort for generating final standings. But now, there are too many teams and that software works too slow. You are asked to write a program, which generates exactly the same final standings as old software, but fast.
Input
The first line of input contains only integer 1 < N ≤ 150000 — number of teams. Each of the next Nlines contains two integers 1 ≤ ID ≤ 107 and 0 ≤ M ≤ 100. ID — unique number of team, M — number of solved problems.
Output
Output should contain N lines with two integers ID and M on each. Lines should be sorted by M in descending order using bubble sort (or analog).
Sample
81 216 311 220 33 526 47 122 4
3 526 422 416 320 31 211 27 1
Hint
Bubble sort works following way:
while (exists A[i] and A[i+1] such as A[i] < A[i+1]) do
Swap(A[i], A[i+1]);
Problem Author: Pavel Atnashev
Problem Source: Tetrahedron Team Contest May 2001
Problem Source: Tetrahedron Team Contest May 2001
/** * * 题目要求要改进冒泡,这就要求排序稳定 * m是100以内的整数,可以用桶排序 * */#include <iostream>#include <cstdio>using namespace std;int id[150005],m[150005];int main(){ int i,j,n; scanf("%d",&n); for(i=0; i<n; i++) scanf("%d%d",&id[i],&m[i]); for(i=100; i>=0; i--) for(j=0; j<n; j++) if(m[j]==i) printf("%d %d\n",id[j],m[j]); return 0;}
- Ural 1100. Final Standings 桶排序
- ural 1100. Final Standings -排序
- URAL 1100. Final Standings (排序)
- Ural 1100. Final Standings
- [URAL 1100]Final Standings(排序技巧)
- Ural 1100 Final Standings
- 1100. Final Standings
- ural1100--Final Standings--数据结构--结构体排序
- Final Standings
- Timus Online Judge:1100. Final Standings
- zoj1444 Final Standings解题报告
- 湖大训练赛第十场 Final Standings
- URAL 1022 拓扑排序
- Ural 1022 拓扑排序
- URAL 1522 Factory 特殊排序
- TOJ 2881.Biased Standings
- tree standings 树 && dp
- 【基础拓扑排序】poj 2376/ural 1022
- 2013腾讯编程马拉松初赛第〇场(3月20日)HDOJ 4504 威威猫系列故事——篮球梦
- 枚举排列球的取出方式
- HDU-1024
- MP3格式文件以及编解码
- 使用Camtasia Player录制多媒体教学视频
- Ural 1100. Final Standings 桶排序
- 基于STM32的USB枚举过程学习笔记(一)
- Python常用类库TOP
- HDU1058 Humble Numbers
- 基于STM32的USB枚举过程学习笔记(二)
- hdu1102Constructing Roads(prim)
- epoll_create, epoll_ctl和epoll_wait 实例讲解,总结得不错
- 13暑假集训#7 总结
- 游戏发布后大小跟哪些因素有关