1306. Sorting Algorithm 2016 12 30
1306. Sorting Algorithm
Constraints
Time Limit: 1 secs, Memory Limit: 32 MB
Description
One of the fundamental problems of computer science is ordering a list of items. There're a plethora of solutions to this problem, known as sorting algorithms. Some sorting algorithms are simple and intuitive, such as the bubble sort. Others, such as the heap sort are not so simple, but produce lightening-fast results.
In the following is a list of some sorting algorithms. Of course, I can’t tell you how to implement them here. You must use your own knowledge.
Bubble sort
Heap sort
Insertion sort
Merge sort
Quick sort
Selection sort
Shell sort
…
My business here is to give you some numbers, and to sort them is your business. Attention, I want the smallest number at the top of the sorted list.
Input
The input file will consist of series data sets. Each data set has two parts. The first part contains two non-negative integers, n (1≤n≤100,000) and m (1≤m≤n), representing the total of numbers you will get and interval of the output sorted list. The second part contains n positive integers. I am sure that each integer in this part will be less than 2,000,000,000.
The input is terminated by a line with two zeros.
Output
For one data set, you should output several numbers in ONE line. After you get the sorted list, you should output the first number of each m numbers, and you should print exact ONE space between two adjacent numbers. And please make sure that there should NOT be any blank line between outputs of two adjacent data sets.
Sample Input
8 2
3
5
7
1
8
6
4
2
0 0
Sample Output
1 3 5 7
Problem Source
ZSUACM Team Member
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
priority_queue< int,vector<int>,greater<int> > que;
int main(){
int n,m;
while(cin>>n>>m&&n!=&&m!=){
int a;
for(int i=;i<n;i++){
cin>>a;
que.push(a);
}
int t = que.top();
cout<<t;
que.pop();
int cnt = ;
while(!que.empty()){
int t = que.top();
que.pop();
if(cnt%m==){
cout<<' '<<t;
}
cnt = (cnt+)%m;
}
cout<<endl;
}
return ;
}
1306. Sorting Algorithm 2016 12 30的更多相关文章
- U3D笔记11:47 2016/11/30-15:15 2016/12/19
11:47 2016/11/30Before you can load a level you have to add it to the list of levels used in the gam ...
- My latest news(--2016.12.31)
2016.12.31 前一天晚上看 “纪实新闻” ,白天看视频,晚上刷题,看电影<湄公河行动> 2016.12.30 18:36 昨天上午考完了本学期的最后一门课程,下午乒乓+值班,今天 ...
- Understand:高效代码静态分析神器详解(一) | 墨香博客 http://www.codemx.cn/2016/04/30/Understand01/
Understand:高效代码静态分析神器详解(一) | 墨香博客 http://www.codemx.cn/2016/04/30/Understand01/ ===== 之前用Windows系统,一 ...
- 2018.12.30【NOIP提高组】模拟赛C组总结
2018.12.30[NOIP提高组]模拟赛C组总结 今天成功回归开始做比赛 感觉十分良(zhōng)好(chà). 统计数字(count.pas/c/cpp) 字符串的展开(expand.pas/c ...
- mysql查询练习题-2016.12.16
>>>>>>>>>> 练习时间:2016.12.16 编辑时间:2016-12-20-->22:12:08 题: 涉及:多表查询.ex ...
- 关于2016.12.12——T1的反思:凸包的意义与应用
2016.12.12 T1 给n个圆,保证圆圆相离,求将圆围起来的最小周长.n<=100 就像上图.考场上,我就想用切线的角度来做凸包.以圆心x,y排序,像点凸包一样,不过用两圆之间的下切线角度 ...
- rhel 7.0 配置centos yum源(2016/12/8),成功!
1.首先查看redhat 7.0系统本身所安装的那些yum 软件包: rpm -qa | grep yum #列出所有已安装的yum包 2.删除这些包: rpm -e *.rpm --nodeps # ...
- 更新日志(建议升级到2016.12.17) && 更新程序的方法
更新程序的方法: 1,在控制面板里点击备份当前数据库文件到磁盘,把当天获取的信息从内存写到磁盘/存储卡.2,下载最新版的源码 wget -O "infopi.zip" " ...
- Oracle中把一个DateTime的字符串转化成date类型。to_date('2016/12/8 18:55:43','yyyy/MM/dd hh24:mi:ss'),
Oracle中把一个DateTime或者该形态字符串转化成date类型. to_date('2016/12/8 18:55:43','yyyy/MM/dd hh24:mi:ss'), 或者: sele ...
随机推荐
- 第四章ContentProvider
No resource found that matches the given name 'Theme.AppCompat.Light'.
- 用贝赛尔曲线把图片, 按钮, label 绘成圆 或圆角矩形
//创建圆形遮罩,把用户头像变成圆形 /* *CGPointMake(35, 35) 是绘图的中心点, 如果想把控件居中绘圆, 一般用控件的中心点, radius 是圆半径 startAn ...
- android Activity绑定Service
activity可以绑定Service,并且可以调用Service中定义的方法 Service代码:在里面多了一个IBinder;个人理解是用来与Activity绑定的主要通道: public cla ...
- svn各个图标代表什么意思
最近参与公司项目开发要使用SVN,下面随笔记下在使用SVN中常见的图标各代表什么意思 灰色向右箭头:本地修改过 ,本地代码没有及时上库.灰色向右且中间有个加号的箭头:本地比SVN上多出的文件灰色向右且 ...
- 串口控RGB三色灯
本文由博主原创,如有不对之处请指明,转载请说明出处. /********************************* 代码功能:串口控RGB三色灯 使用函数: Serial.flush(); / ...
- iOS 判断设备型号
+ (NSString*)deviceString { // 需要#import "sys/utsname.h" struct utsname systemInfo; uname( ...
- Appium移动自动化测试之Eclipse
下载eclipse,这个下载方式比较多,eclipse官网,CSDN都有的下,版本根据自己操作系统选择,切记eclipse版本一定要与JDK版本一至,不然eclipse无法启动.现在我们来搭建Andr ...
- myeclipse部署web项目到server : deploy location 为 INVALID,并且不能更改
首先查看项目路径下有没有 .mymetadata文件,没有就从其它地方挪一个,但是文件中的id必须是唯一的. 如果还不行就去下面这位大哥写的博客看下,进行下一步就可以解决了 生如夏花
- ios 按钮点击无反应
今天项目遇到有个UIButton无法点击,弄了半天,总结出以下几个结论 1.如果一个UIButton的frame超出父视图的frame,UIButton还是可以显现的,但响应不了点击事件了,当开发中, ...
- for xml 字符串拼接
SELECT TOP 10 B.user_gid,LEFT(StuList,LEN(StuList)-1) as hobby FROM (SELECT user_gid,( SELECT CAST(a ...