Description

FJ is surveying his herd to find the most average cow. He wants to know how much milk this 'median' cow gives: half of the cows give as much or more than the median; half give as much or less. Given an odd number of cows N (1 <= N < 10,000) and their milk output (1..1,000,000), find the median amount of milk given such that at least half the cows give the same amount of milk or more and at least half give the same or less. 输入N个数,输出升序排列后中间那个数.

Input

* Line 1: A single integer N * Lines 2..N+1: Each line contains a single integer that is the milk output of one cow.

Output

* Line 1: A single integer that is the median milk output.

Sample Input

5
2
4
1
3
5

INPUT DETAILS:

Five cows with milk outputs of 1..5

Sample Output

3

OUTPUT DETAILS:

1 and 2 are below 3; 4 and 5 are above 3.

金组题就是输出中位数……这题目是不是出的有问题……

#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,a[10010];
int main()
{
n=read();
for (int i=1;i<=n;i++)a[i]=read();
sort(a+1,a+n+1);
printf("%d",a[(1+n)>>1]);
return 0;
}

  

bzoj1753 [Usaco2005 qua]Who's in the Middle的更多相关文章

  1. 1753: [Usaco2005 qua]Who's in the Middle

    1753: [Usaco2005 qua]Who's in the Middle Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 290  Solved:  ...

  2. bzoj 1753: [Usaco2005 qua]Who's in the Middle【排序】

    --这可能是早年Pascal盛行的时候考排序的吧居然还是Glod-- #include<iostream> #include<cstdio> #include<algor ...

  3. BZOJ1754: [Usaco2005 qua]Bull Math

    1754: [Usaco2005 qua]Bull Math Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 374  Solved: 227[Submit ...

  4. bzoj1751 [Usaco2005 qua]Lake Counting

    1751: [Usaco2005 qua]Lake Counting Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 168  Solved: 130 [ ...

  5. 1755: [Usaco2005 qua]Bank Interest

    1755: [Usaco2005 qua]Bank Interest Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 187  Solved: 162[Su ...

  6. 1754: [Usaco2005 qua]Bull Math

    1754: [Usaco2005 qua]Bull Math Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 398  Solved: 242[Submit ...

  7. 1751: [Usaco2005 qua]Lake Counting

    1751: [Usaco2005 qua]Lake Counting Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 190  Solved: 150[Su ...

  8. bzoj3384[Usaco2004 Nov]Apple Catching 接苹果*&&bzoj1750[Usaco2005 qua]Apple Catching*

    bzoj3384[Usaco2004 Nov]Apple Catching 接苹果 bzoj1750[Usaco2005 qua]Apple Catching 题意: 两棵树,每分钟会从其中一棵树上掉 ...

  9. BZOJ 1754: [Usaco2005 qua]Bull Math

    Description Bulls are so much better at math than the cows. They can multiply huge integers together ...

随机推荐

  1. 淡淡de馨香---职业尊严

    大学四年时光匆匆而过,仿佛一切都不曾远去,那种熟悉又激动的感觉好似就在昨天,但是.一切都仅仅是一种感觉,在现实面前没有谁能够逆天,在被遗忘的什么时候,曾经是想着无数的梦想与自定义,同样也是在被遗忘的什 ...

  2. PHP中文汉字验证码

    hb.ttf换成随便你自己下载的ttf Header("Content-type: image/PNG"); $str="的一是在了不和有大这主中人上为们地个用工时要动国 ...

  3. PHP的错误处理方式

    错误类型 PHP 主要有两种错误:触发错误和异常.其中触发错误大概可以分为:编译错误.引擎错误和运行时错误,其中前两个是无法捕获的:异常都是可以捕获的,当没有尝试捕获时则会中断代码. 触发错误可以通过 ...

  4. 万恶DevExpress

    公司需要,开始了DevExpress的学习之旅,说它万恶也只是在不了解它的情况下,熟悉之后能很方便的实现很多想要的功能 这里简单写一下要整理的内容,也就是大纲,以后再慢慢添加 一.控件和组件 date ...

  5. 5狐网教你从零基础做Firefox os 手机应用开发赚money

    如果你还没有接触过web编程,这里有基础教程教你怎样一步一步学习开发,如果你已经是一个web编程基础的人,那你就很容易将web编程放到手机上,轻松教你移植web应用游戏到Firefox手机应用再发布到 ...

  6. 大话分页(补充)——Threadlocal封装offSet和pageSize简化分页工具类

    经过前两篇文章(大话分页一.大话分页二)的介绍,我认为我想介绍的东西已经介绍完了,不过想精益求精的童鞋可以继续看本篇文章. 在第一篇文章中介绍了一个分页的工具类(具体请看大话分页一),从实现功能上来说 ...

  7. [RxJS] Displaying Initial Data with StartWith

    You often need to render out data before you stream begins from a click or another user interaction. ...

  8. 在Ubuntu上下载、编译和安装Android最新内核源代码(Linux Kernel)

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6564592 在前一篇文章提到,从源代码树下载下 ...

  9. Oracle数据库的创建与验证

    创建数据库,输入命令dbca创建数据库 会弹出创建数据库相应的对话框 单击下一步 选择创建一个数据库,并单击下一步 数据库模板选择一般目的的转换过程即可.单击下一步 全局数据库名称和SID名称,要和上 ...

  10. js_day8