poj 2623 Sequence Median 堆的灵活运用
Time Limit:1000MS Memory Limit:1024KB 64bit IO Format:%I64d & %I64u
Description
Input
Output
Sample Input
input | output |
---|---|
4 |
4.5 |
这道题 你会发现存不下,只能存一半
然后瞎搞搞,就出来了
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 100001
const int inf=0x7fffffff; //无限大
priority_queue<unsigned int> q;
int main()
{
int n;
while(cin>>n)
{
while(!q.empty())
q.pop();
unsigned int x;
int kill=n/+;
unsigned int fuck;
for(int i=;i<kill;i++)
{
cin>>x;
q.push(x);
}
for(int i=kill;i<n;i++)
{
cin>>x;
fuck=q.top();
if(x<fuck)
{
q.pop();
q.push(x);
}
}
if(n%==)
{
unsigned int a=q.top();
q.pop();
unsigned int b=q.top();
printf("%.1lf\n",(a+b)/2.0);
}
else
{
unsigned int a=q.top();
printf("%.1lf\n",a*1.0);
}
}
return ;
}
poj 2623 Sequence Median 堆的灵活运用的更多相关文章
- (poj)Sequence Median
Description Given a sequence of N nonnegative integers. Let's define the median of such sequence. If ...
- POJ 2442 Sequence【堆】
题目链接:http://poj.org/problem?id=2442 题目大意:给出一个m*n的矩阵,从每一行中取出一个数相加.能得到n^m个不同的结果.要求输出当中前n项. 建立一个以n元数组为底 ...
- ural 1306. Sequence Median
1306. Sequence Median Time limit: 1.0 secondMemory limit: 1 MBLanguage limit: C, C++, Pascal Given a ...
- [POJ 3581]Sequence
[POJ 3581]Sequence 标签: 后缀数组 题目链接 题意 给你一串序列\(A_i\),保证对于$ \forall i \in [2,n],都有A_1 >A_i$. 现在需要把这个序 ...
- Running Median POJ - 3784 (对顶堆/优先队列 | 链表)
For this problem, you will write a program that reads in a sequence of 32-bit signed integers. After ...
- POJ 2442 - Sequence - [小顶堆][优先队列]
题目链接:http://poj.org/problem?id=2442 Time Limit: 6000MS Memory Limit: 65536K Description Given m sequ ...
- POJ 2442 Sequence(堆的使用练习)
题目地址:id=2442">POJ 2442 真心没想到这题的思路. .原来是从第一行逐步向下加,每次都仅仅保存前n小的数.顺便练习了下堆.. 只是感觉堆的这样的使用方法用的不太多啊. ...
- POJ 2442 Sequence堆 优先队列
题目描述 给定m个序列,每个序列包含n个非负整数.现在我们可以从每个序列中选择一个数字以形成一个具有m个整数的序列.显然,我们可以得到n ^ m种这种序列.然后,我们可以计算每个序列中的数字总和,并获 ...
- POJ 3784 Running Median(动态维护中位数)
Description For this problem, you will write a program that reads in a sequence of 32-bit signed int ...
随机推荐
- socket相关系统调用的调用流程
最近一直在读内核网络协议栈源码,这里以ipv4/tcp为例对socket相关系统调用的流程做一个简要整理,这些相关系统调用的内部细节虽然各有不同,但其调用流程则基本一致: 调用流程: (1)系统调用 ...
- Codeforces Round #504 E. Down or Right
Codeforces Round #504 E. Down or Right 题目描述:交互题. 有一个\(n \times n\)的方阵,有一些格子是障碍,从\((1, 1)\)出发,只能向右向下走 ...
- 记录一款Unity VR视频播放器插件的开发
效果图 先上一个效果图: 背景 公司最近在做VR直播平台,VR开发我们用到了Unity,而在Unity中播放视频就需要一款视频插件,我们调研了几个视频插件,记录两个,如下: Unity视频插件调研 网 ...
- No.15 selenium for python JavaScript
JS处理滚动条 一.上下滚动 1.滚动条回到顶部: js="var q=document.documentElement.scrollTop=10000" driver.execu ...
- java多线程-读写锁原理
Java5 在 java.util.concurrent 包中已经包含了读写锁.尽管如此,我们还是应该了解其实现背后的原理. 读/写锁的 Java 实现(Read / Write Lock Java ...
- 左列動態添加菜單Repeater
前台代碼: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="left.aspx. ...
- MySQL学习笔记:regexp正则表达式
在MySQL中,模糊搜索的时候主要用两种方式: 1.like2.regexp + 正则表达式 性能优于like 正则表达式描述了一组字符串. 最简单的正则表达式是不含任何特殊字符的正则表达式.例如,正 ...
- Struts 2 - Hello World Example
As you learnt from the Struts 2 architecture, when you click on a hyperlink or submit an HTML form i ...
- tomcat 内存参数优化示例
https://www.cnblogs.com/cornerxin/p/9304100.html
- CCF CSP 201709-2 公共钥匙盒
CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201709-2 公共钥匙盒 问题描述 有一个学校的老师共用N个教室,按照规定,所有的钥匙都必须 ...