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 ...
随机推荐
- Git 添加自己分支 pull request
1.找到项目地址 这里,我们可以找到项目地址,比如:https://github.com/*****/Cplusplus_Thread_Lib,然后点击页面右上角的 "fork" ...
- 关于在vs中添加生成命令时的注意事项
涉及到目录最好用双引号括起来,防止在目录含有空格或文字时发生错误.例如 del "$(SolutionDir)\..\xxxxxx\xxxx\Build\*.*" /s /q xc ...
- .net通过WCF调用java发布的服务,获取数据
功能描述 java作为后台,连接数据库获取数据,然后发布SOAP services,让.net平台通过WCF进行引用. 实现步骤 1.在项目特定文件夹下,右键->添加服务引用,输入服务的url地 ...
- Toast用法
应用场景:弹出提示信息 主界面: 代码如下: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(sa ...
- sql 查看语句的性能
SET STATISTICS TIME:看cpu时间 SET STATISTICS IO:关注scan count(计数)------查询读取的表数量:logical read( 逻辑读)次数
- Scala学习---映射和元祖
1.设置一个映射,其中包含你想要的一些装备,以及他们的价格.然后构建另一个映射,采用同一组键,但在价格上打9折. scala> val map = Map("a"->1 ...
- oracle 字段类型详解
CHAR 固定长度字符串 最大长度2000 bytes VARCHAR2 可变长度的字符串 最大长度4000 bytes 可做索引的最大长度749 NCHAR 根据字符集而定的固定长度字符串 最大长度 ...
- 第二节windows系统下Xshell 5软件远程访问虚拟机 Linux系统
下载Xshell 5软件在windows下安装 安装好后Xshell 5启动软件 下一步,检查虚拟机,配置是否正确 下一步,设置网络,保障虚拟机系统能够连接网络 下一步,进入虚拟机系统,检查虚拟机网络 ...
- Python学习笔记_Chapter 6定制数据对象
1. 有用的BIF a. 判断字符串中是否包含子字符串 if s_a in s_b: b. pop() 描述:从指定的列表位置删除并返回一个数据项. (sarah_name,sarah_dob)=l_ ...
- hdu_5874_Friends and Enemies(公式题)
题目链接:hdu_5874_Friends and Enemies 题意: 有nn个人, mm种颜色的石头, 人两两之间要么是朋友, 要么是敌人. 每个人可以携带若干种石头或者不带, 要求朋友之间至少 ...