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 ...
随机推荐
- Hcm data loader for cancel work relationship
好好总结一下这个task.没有做好的东西:1.现有的资料和各种各样的工具没有很好的利用起来,造成了用了很多的时间去了解和自己学习.非常的不舒服的.下次要避免这样的浪费时间,学会在工作中学习.现在以及以 ...
- 使用CSS完美实现垂直居中的方法
使用XHTML+CSS来实现元素的垂直居中一直是前端开发中的一个比较复杂且棘手的问题,作为网页设计师或前端开发工程师,这个垂直居中问题也是必须掌握的技巧之一,一些互联网公司面试题中也会出现这类题目.今 ...
- vim 大全用法
vim中常用设置和操作: 在Linux系统下: 打开vi 文件: 0 数字0,跳转至行首 ^ 跳转至行第一个非空字符 $ 跳转至行尾 vim 括号匹配跳转操作: ctrl+] 跳转至函数或 ...
- 关于c#调用c编译器
这个已经过了好久了具体的实现代码没得,但是大致思路自己整理了一下: 首先要调用c编译器,process.start(): 之后需要自己来进行编译器对代码执行的命令.
- 关于jQuery中环境配置中的问题
一开始无法显示出效果,配置和代码如 这代码本没有错 但是就是无法显示 原因是我下载了2.x版本的jQuery,jQuery2.x版本是不支持IE6/7/8的,也有很多主流的浏览器无法显示出效果,于是在 ...
- 关于ajax载入窗口使用RedirectToAction在窗口显示的问题
在过滤器中过滤用户是否登录,没有登录就RedirectToAction("Login", "Auth", new { Area = "Account& ...
- CocoaPod安装和使用教程
一.CocoaPods是什么? CocoaPods是一个负责管理iOS项目中第三方开源库的工具.CocoaPods的项目源码在Github上管理.我们开发iOS项目不可避免地要使用第三方开源库,Coc ...
- shll 变量
name=zhagnsan age=11 echo $ name $age 赋值号两边没有任何空格.当想取shell变量的值时,需要在变量名前加上$字符,当所赋的值中间含有空格时,要加上引号 函数: ...
- linux内核升级图文攻略(转)
一.Linux内核概览Linux是一个一体化内核(monolithic kernel)系统.设备驱动程序可以完全访问硬件.Linux内的设备驱动程序可以方便地以模块化(modularize)的形式设置 ...
- 关于js原型继承
js的每个类都有一个prototype对象 访问对象的属性时,会先访问到对象自身是否有定义这个属性 如果没有定义,就会去访问对象所属类型的prototype对象是否有此属性 原型继承就是把类型的pro ...