ural 1306. Sequence Median
1306. Sequence Median
Memory limit: 1 MB
Language limit: C, C++, Pascal
Input
Output
Sample
| input | output |
|---|---|
4 |
4.5 |
#include <cstdio>
#include <queue>
#include <iostream>
using namespace std;
inline void SetIO(string Name)
{
string Input = Name+".in",
Output = Name+".out";
freopen(Input.c_str(), "r", stdin),
freopen(Output.c_str(), "w", stdout);
} int n, Arr[ / + ]; inline void Input()
{
scanf("%d", &n);
} inline void Solve()
{
for(int i = ; i < n / + ; i++) scanf("%d", &Arr[i]);
make_heap(Arr, Arr + n / + );
for(int i = n / + ; i < n; i++)
{
scanf("%d", &Arr[n / + ]);
push_heap(Arr, Arr + n / + );
pop_heap(Arr, Arr + n / + );
}
if(n & ) printf("%.1lf\n",1.0 * Arr[]);
else
{
unsigned int x = Arr[];
pop_heap(Arr, Arr + n / + );
unsigned int y = Arr[];
printf("%.1lf\n", 1.0 * (x + y) / 2.0);
}
} int main()
{
#ifndef ONLINE_JUDGE
SetIO("G");
#endif
Input();
Solve();
return ;
}
ural 1306. Sequence Median的更多相关文章
- URAL 1306 Sequence Median(优先队列)
题意:求一串数字里的中位数.内存为1M.每个数范围是0到2的31次方-1. 思路:很容易想到把数字全部读入,然后排序,但是会超内存.用计数排序但是数又太大.由于我们只需要第n/2.n/2+1大(n为偶 ...
- URAL 1306 - Sequence Median 小内存求中位数
[题意]给出n(1~250000)个数(int以内),求中位数 [题解]一开始直接sort,发现MLE,才发现内存限制1024k,那么就不能开int[250000]的数组了(4*250000=1,00 ...
- 1306.Sequence Median(堆排序)
1306 URAL真是没水题 以为简单的排序就好了 ME 内存限制很紧 堆排序 或者 STL 用堆排序做的 正好复习一下 都忘了 #include <iostream> #include ...
- poj 2623 Sequence Median 堆的灵活运用
I - Sequence Median Time Limit:1000MS Memory Limit:1024KB 64bit IO Format:%I64d & %I64u ...
- Ural 1248 Sequence Sum 题解
目录 Ural 1248 Sequence Sum 题解 题意 题解 程序 Ural 1248 Sequence Sum 题解 题意 给定\(n\)个用科学计数法表示的实数\((10^{-100}\s ...
- (poj)Sequence Median
Description Given a sequence of N nonnegative integers. Let's define the median of such sequence. If ...
- URAL1306 Sequence Median(卡内存神题)
给出n个数,n<=250000,求这n个数的中位数,内存限制1mb 卡内存的神题,用数组存下来刚好1mb,再加上执行时消耗内存.立即爆. 因此我们用优先队列存储一半的数. 网上的某些代码,用pr ...
- 二分法&三分法
ural History Exam 二分 #include <iostream> #include <cstdlib> using namespace std; //二分 ...
- 投入OJ的怀抱~~~~~~~~~~
OpenJudge C20182024 信箱(1) 账号 修改设定 退出小组 管理员 frank 林舒 Dzx someone 李文新 公告 11-05 程序设计与算法(大学先修课) 成员(61910 ...
随机推荐
- rails获取json内容
文章是从我的个人博客上粘贴过来的, 大家也可以访问 www.iwangzheng.com url点开后的json是这样的 { e: { provider: ”searches.soku.top”, ...
- poj2993 翻转2996
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2944 Accepted: ...
- poj1182(食物链)续
意 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种. 有人用 ...
- poj1611(感染病患者)
The Suspects Time Limit: 1000MS Memory Limit: 20000K Total Submissions: 24587 Accepted: 12046 De ...
- Android自动登录与记住密码
// 获取实例对象 sp = this.getSharedPreferences("userInfo", Context.MODE_WORLD_READABLE); rem_pw ...
- 在VMware的虚拟机平台上如何进行网络设置
1.本文构建的是这样一个网络,有两台winXP系统的PC,处于同一局域网内,PC里 都装有VMware虚拟机,虚拟机上跑的是Redhat Linux 9,我们想要在winXP系统下访问本机的虚拟机li ...
- SCOPE_IDENTITY的作用
SCOPE_IDENTITY返回插入到同一作用域中的 IDENTITY 列内的最后一个 IDENTITY 值.一个作用域就是一个模块——存储过程.触发器.函数或批处理.因此,如果两个语句处于同一个存储 ...
- 《ASP.NET1200例》各种类型文件汇总
aspx是页面文件 ascx是用户控件,用户控件必须嵌入到aspx中才能使用. ascx是用户控件,相当于模板 其实ascx你可以理解为Html里的一部分代码, 只是嵌到aspx里而已, 因为aspx ...
- jquery优势
1.轻量 2.开源 3.选择器出色 可以支持几乎 css1到css3 的所有选择器 4.简单的修改页面 不同的浏览器对于css的支持程度是不同的,jquery通过封装javascript的代码, ...
- Meta Programming
[本文链接] http://www.cnblogs.com/hellogiser/p/meta-programming.html [分析] Template Mataprogram,中文叫模板元编程. ...