优先级队列

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
int n;
int main()
{
while(~scanf("%d",&n))
{
int tot=;
priority_queue<int>Q;
while(n--)
{
int x;
scanf("%d",&x);
if(x==)
{
int u;
scanf("%d",&u);
tot++;
Q.push(u);
}
else if(x==)
{
if(tot==) printf("-1\n");
else
{
int r=tot-(tot/+);
while(r--) Q.pop();
int h=Q.top();
printf("%d\n",h);
tot=(tot/+);
}
}
}
}
return ;
}

NEU OJ 1644 Median I的更多相关文章

  1. LeetCode OJ 4. Median of Two Sorted Arrays

    There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two ...

  2. 【LeetCode OJ】Median of Two Sorted Arrays

    题目链接:https://leetcode.com/problems/median-of-two-sorted-arrays/ 题目:There are two sorted arrays nums1 ...

  3. 九度oj 1004 Median 2011年浙江大学计算机及软件工程研究生机试真题

    题目1004:Median 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:14162 解决:3887 题目描述: Given an increasing sequence S of N i ...

  4. NEU OJ 1651 Great number

    循环节是2000000016 字符串读入,用一下高精度对2000000016取个模,用一下快速幂就可以算出答案了. #include <cstdio> #include <iostr ...

  5. NEU OJ 1649 GMZ’s Pretty Number

    先来一次线性素数筛,把1到10000000的素数都筛选出来,然后暴力跑一遍所有可能的值,打个表,查询的时候o(1)效率出解. #include<cstdio> #include<cs ...

  6. Solve Equation gcd(x,y)=gcd(x+y,lcm(x,y)) gcd(x,y)=1 => gcd(x*y,x+y)=1

    /** 题目:Solve Equation 链接:http://acm.hnust.edu.cn/JudgeOnline/problem.php?id=1643 //最终来源neu oj 2014新生 ...

  7. [OJ] Data Stream Median (Hard)

    LintCode 81. Data Stream Median (Hard) 思路: 用一个大根堆保存较小的一半数, 一个小根堆保存较大的一半数. 每次根据num和两个堆顶的数据决定往哪个堆里面放. ...

  8. LeetCode OJ:Find Median from Data Stream(找数据流的中数)

    Median is the middle value in an ordered integer list. If the size of the list is even, there is no ...

  9. 九度OJ 1004:Median

    #include <stdio.h> #include <stdlib.h> #include <limits.h> #define N 1000000 int a ...

随机推荐

  1. S.O.L.I.D五大原则之单一职责SRP

    转自 : 汤姆大叔的blog Bob大叔提出并发扬了S.O.L.I.D五大原则,用来更好地进行面向对象编程,五大原则分别是: The Single Responsibility Principle(单 ...

  2. mybatis处理特殊符号

    当我们需要通过xml格式处理sql语句时,经常会用到< ,<=,>,>=等符号,但是很容易引起xml格式的错误,这样会导致后台将xml字符串转换为xml文档时报错,从而导致程序 ...

  3. 小白学C++的小问题

    昨天开始学习C++,使用的visual studio 2012. 1命名要有意义,避免用a,b,c,尽量使用num,result等让人看见就能明白相关含义的名字 2要有一定的注释,注释和有意义的命名可 ...

  4. java 生成证书用于https

    在jdk的bin目录下运行: keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore " ...

  5. 【JS】学习18天Jquery Moblie的总结笔记。

    现在是2013年11月18日1:53分,从1号开始学习JqueryMoblie(简称JQM),这些天遇到的问题,和走的弯路还真不少. 先做个小总结,做了那么多天的一些收获: ●JQM是一个手机网站/轻 ...

  6. sqlserver跨数据库与跨服务器使用

    sqlserver跨数据库与跨服务器使用 日常数据库编程中经常会遇到需要跨数据库和跨服务器的情况,本文总结解决方法,具体如下: 工具/原料 SQLSERVER 数据库 方法/步骤   跨数据库使用比较 ...

  7. mysql允许远程连接授权方法

    mysql数据库和apache不在同一台服务器时,需要远程连接mysql,这就要对mysql进行远程连接授权,为了安全只允许某些ip可以连接: 假如你想root用户从ip 192.168.2.12连接 ...

  8. 修改VirtualBox虚拟机默认存储路径及虚拟机迁移方法

    修改默认安装路径 在安装完虚拟机以后发现我的虚拟的磁盘文件是放在C盘的,就想着有没有办法修改默认存储路径.后来发现确实可以修改,修改虚拟机方法如下:"管理"--->" ...

  9. WITH common_table_expression

    Feature: 公用表表达式只能包含一个SELECT,多SELECT需UNION,UNION ALL 公用表表达式只能引用一次 公用表表达式可以包括对自身的引用,这种表达式称为递归公用表表达式 -- ...

  10. 为啥使用Iscroll.js之后,a不能触发点击事件?

    原因:是iscroll.js阻止了a的行为. 解决方法:打开iscroll-probe.js,然后找到preventDefaultException方法. 然后修改为: // preventDefau ...