POJ 1442 Black Box 优先队列 求前a[k]个数中第k大的数
来源:互联网 发布:一度教育java 编辑:程序博客网 时间:2024/05/21 08:39
维护两个队列,
开A
#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <vector>#include <set>#include <map>#include <stack>#include <queue>using namespace std;int a[31000];int main(){ int m, n; scanf("%d %d", &m, &n); int i, j; for(i = 0;i < m;i++){ scanf("%d", &a[i]); } int k; priority_queue<int, vector<int>, less<int> >big; priority_queue<int, vector<int>, greater<int> >small; j = 0; int t; for(i = 1;i <= n;i++){ scanf("%d", &k); while(j < k){ small.push(a[j]); if(!big.empty()&&small.top() < big.top()){ t = big.top(); big.pop(); big.push(small.top()); small.pop(); small.push(t); } j++; } printf("%d\n", small.top()); big.push(small.top()); small.pop(); } return 0;}
0 0
- POJ 1442 Black Box 优先队列 求前a[k]个数中第k大的数
- POJ 1442 Black Box treap求区间第k大
- 求n个数中第k大的数、前K大的数、快速排序
- poj 1442 Black Box(trap模板 求整个序列的第k大
- STL--H - Black Box(两个优先队列,求第k小的值)
- hdu(4006)优先队列求第K大的数
- POJ 1442-Black Box(动态区间第K小-优先队列)
- POJ 1442 Black Box 升序询问第k小 优先队列 / Treap
- POJ 1442 Black box(单调队列求第k小数)
- POJ 1442 Black Box(【Treap】求动态区间第k大)
- 【POJ】1442 Black Box 静态第k大,treap
- POJ 1442 Black Box treap裸题 动态求整个序列的前k大数
- 求一个数组中前K大的数或者第K大的数
- 面试题: 求N个数中前k个大的数(大数据)
- BFPTR算法(中位数的中位数算法)求n个数中第k大的数
- 求n个数中第k大的数、快速排序
- 分治算法求N个数中第K小(大)的数
- C#求数组中前K大的数
- 每日一linux命令(49)-------ln 命令
- kernel 中circle buffer的使用
- JavaIO知识小结和操作规律
- 七层OSI和四层网络模型
- 杂七杂八的概念
- POJ 1442 Black Box 优先队列 求前a[k]个数中第k大的数
- VS2013未能正确加载的问题
- 7.grep和正则
- 集合中存储时的对象重写比较方法
- JSP——过滤器篇
- 物理?数学题
- Catch That Cow
- Unity3d的GameObject.Find()的一些使用心得体会
- 中国剩余定理解说与整理