hdu 4006 The kth great number 优先级队列
来源:互联网 发布:java程序员分级 编辑:程序博客网 时间:2024/05/16 11:21
#include<iostream>
using namespace std;
#include<queue>
struct node
{
int num;
friend bool operator < (node a,node b)
{
return a.num>b.num;
}
} a[100005];
int main()
{
int n,k;
int x;
char cha;
priority_queue<node> ms;
while(cin>>n>>k)
{
int cout=0;
while(!ms.empty())
ms.pop();
while(n--)
{
getchar();
scanf("%c",&cha);
if(cha=='I')
{
scanf("%d",&x);
cout++;
a[cout].num=x;
ms.push(a[cout]);
if(cout>k)
ms.pop();
}
else
printf("%d\n",(ms.top()).num);
}
}
return 0;
}
using namespace std;
#include<queue>
struct node
{
int num;
friend bool operator < (node a,node b)
{
return a.num>b.num;
}
} a[100005];
int main()
{
int n,k;
int x;
char cha;
priority_queue<node> ms;
while(cin>>n>>k)
{
int cout=0;
while(!ms.empty())
ms.pop();
while(n--)
{
getchar();
scanf("%c",&cha);
if(cha=='I')
{
scanf("%d",&x);
cout++;
a[cout].num=x;
ms.push(a[cout]);
if(cout>k)
ms.pop();
}
else
printf("%d\n",(ms.top()).num);
}
}
return 0;
}
- hdu 4006 The kth great number 优先级队列
- HDU 4006 The kth great number 【队列】
- hdoj 4006The kth great number(优先级队列)
- HDU 4006 The kth great number 堆/优先级队列/线段树
- hdu 4006 The kth great number(使用优先队列)
- HDU 4006 The kth great number(优先队列、堆实现)
- HDU 4006 The kth great number (堆实现优先队列)
- HDU 4006 The kth great number(优先队列)
- HDU 4006 The kth great number(优先队列)
- hdu 4006 The kth great number(优先队列)
- hdu 4006 The kth great number 优先队列
- HDU-#4006 The kth great number(优先队列)
- HDU 4006 The kth great number【优先队列】
- hdu 4006 The kth great number(优先队列)
- HDU 4006 The kth great number(优先队列)
- hdu杭电4006 The kth great number【优先队列】
- hdu 4006 The kth great number(线段树 || 优先队列)
- HDU 4006 The kth great number(优先队列)
- 职场心理学 让你少奋斗30年
- win7系统下Dreamweaver cs4 出现中文菜单变英文状态解决方法
- object-c用+来表示类方法,相当于声明为static
- 如何计算地球球面上两个坐标点之间的弧度
- Oracle用子查询创建临时表的问题总结
- hdu 4006 The kth great number 优先级队列
- StatSVN插件使用方法总结-项目代码分析工具 工作量图表生成工具
- ORACLE DBA常用SQL
- Python 3.0 编码变动
- 安装Visual Studio.net 2003总是会收到“一个安装程序检测到另一个程序需要重新启动计算机”的错误消息
- myEclipse编辑器大小写转换
- Windows 8 开发版下载
- DB2 CASE/IF 条件控制语句
- 《重构--改善代码的既有设计》阅读笔记之代码的坏味道