NEU OJ 1644 Median I
优先级队列
#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的更多相关文章
- 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 ...
- 【LeetCode OJ】Median of Two Sorted Arrays
题目链接:https://leetcode.com/problems/median-of-two-sorted-arrays/ 题目:There are two sorted arrays nums1 ...
- 九度oj 1004 Median 2011年浙江大学计算机及软件工程研究生机试真题
题目1004:Median 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:14162 解决:3887 题目描述: Given an increasing sequence S of N i ...
- NEU OJ 1651 Great number
循环节是2000000016 字符串读入,用一下高精度对2000000016取个模,用一下快速幂就可以算出答案了. #include <cstdio> #include <iostr ...
- NEU OJ 1649 GMZ’s Pretty Number
先来一次线性素数筛,把1到10000000的素数都筛选出来,然后暴力跑一遍所有可能的值,打个表,查询的时候o(1)效率出解. #include<cstdio> #include<cs ...
- 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新生 ...
- [OJ] Data Stream Median (Hard)
LintCode 81. Data Stream Median (Hard) 思路: 用一个大根堆保存较小的一半数, 一个小根堆保存较大的一半数. 每次根据num和两个堆顶的数据决定往哪个堆里面放. ...
- 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 ...
- 九度OJ 1004:Median
#include <stdio.h> #include <stdlib.h> #include <limits.h> #define N 1000000 int a ...
随机推荐
- 【IE6的疯狂之一】IE6中奇数宽高的BUG
IE6真是太疯狂了.今天由于项目需要做了这么一个布局:一个外部的相对定位div,内部一个绝对定位的div(right:0), 如图: 可是在IE6下查看,却变成了right:1px的效果了: IE6还 ...
- request相关研究
一.什么是httpservletrequest 用来处理一个对Servlet的HTTP格式的请求信息. 二.httpservletrequest的作用是什么 优点: 公共接口类HttpServletR ...
- jsp中获取json字符串,并解析
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title> ...
- C++设计模式-singleton单例模式_new
class nocopyable { protected: nocopyable(){}; virtual ~nocopyable(){}; nocopyable(const nocopyable ...
- Debian7安装php5.5/5.6
### 1 添加源 echo "deb http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources ...
- Android Monkey 测试策略【转】
Monkey 测试针对不同的对象和不同的目的,需要采用不同的测试方案. 首先测试的对象.目的及类型如下: 测试的类型 应用程序的稳定性测试 应用程序的压力测试 测试对象 单一 apk apk 集合 测 ...
- UITableView控制头部View
首先我们先集成一个UIView做一个自己的View #import <UIKit/UIKit.h> @interface MyView : UIView @property (nonato ...
- android基础(一)
wrap_conten:包裹实际文本内容 match_parent:当前控件铺满父类容器:2.3api之后添加的一个属性值 fill_parent:包裹实际文本内容,在2.3api之前的一个属性值 a ...
- servlet 用法
引入servlet的jar包,这个包在tomcat的lib下 新建一个servlet文件继承httpServlet,要实现里面的doGet或者doPost方法 在web.xml文件中配置 在form表 ...
- ggplot2 geom相关设置—点重合处理(jitter)
在R中散点图的时候会经常出现,点重合比较严重的现象,这对我们寻找数据规律或者观察数据有很大的干扰. 所幸的是R中,可以用geom_jitter()函数来调整,消除点的重合. geom_jitter(m ...