HDU 4006 The kth great number(优先队列)
来源:互联网 发布:中国城市化进程数据 编辑:程序博客网 时间:2024/05/20 17:27
由于只有插入操作,所以不很复杂的数据结构,优先队列就可以了,每次保持队列中有k个元素,这样取出的头必然是第k大
代码:
#include <cstdio>#include <cstring>#include <algorithm>#include <queue>using namespace std;int n, k;int main() { while (~scanf("%d%d", &n, &k)) { char s[2]; int x; priority_queue<int, vector<int>, greater<int> > Q; while (n--) { scanf("%s", s); if (s[0] == 'I') scanf("%d", &x), Q.push(x); else { while (Q.size() > k) Q.pop(); printf("%d\n", Q.top()); } } } return 0;}
0 0
- 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 (优先队列)
- 【HDU 4006】The kth great number(优先队列)
- HDU 4006 The kth great number (优先队列)
- 【HDU】-4006-The kth great number(优先队列,好)
- HDU 4004 The Frog's Games (二分贪心)
- HDU 4046 Panda(线段树)
- Qt发布opencv的工程需配置的lib,dll和include等
- HDU 4054 Hexadecimal View(模拟)
- HDU 4055 Number String(dp)
- HDU 4006 The kth great number(优先队列)
- git review (四)
- static_cast与dynamic_cast转换
- ADO.Net Connectivity using Stored Procedure and Output parameters
- erlang虚拟机代码执行原理
- php单一入口模式详细讲解
- C++中的const关键字的用法非常灵活,而使用const将大大改善程序的健壮性,本人根据各方面查到的资料进行总结如下,期望对朋友们有所帮助。 Const 是C++中常用的类型修饰符,常类型是指使用类
- c++一些转换操作
- Soap 协议 详解