Who's in the Middle
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 34974   Accepted: 20396

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.

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

Sample Output

3

Hint

INPUT DETAILS:

Five cows with milk outputs of 1..5

OUTPUT DETAILS:

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

Source

 
 
#include<string.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int s[];
int main(){
int n;
while(scanf("%d",&n)!=EOF){
memset(s,,sizeof(s));
for(int i=;i<n;i++)
scanf("%d",&s[i]);
sort(s,s+n);
printf("%d\n",s[n/]);
}
return ;
}

poj2388 更水的更多相关文章

  1. hdu_1014(竟然真的还有更水的)

    注意输出就没了... #include<cstdio> #include<cstring> using namespace std; int gcd(int a, int b) ...

  2. POJ2301+水~~~~~~

    有比这更水的么.............. #include<stdio.h> int main(){ int n; scanf("%d",&n); while ...

  3. 浅谈MITM攻击之信息窃取(解密315晚会报道的免费WIFI窃取个人信息)

    前言   所谓的MITM攻击(即中间人攻击),简而言之就是第三者通过拦截正常的网络通信数据,并进行数据篡改和嗅探,而通信的双方毫无感知.这个很早就成为黑客常用的手段,一会聊的315晚会窃取个人信息只是 ...

  4. CodeForces 515A

    A. Drazil and Date time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  5. 【BZOJ】【2049】【SDOI2008】洞穴勘测 Cave

    LCT 哦……LCT的一道更水的裸题,适合学习access,link,cut等基本操作(其实这三个不是在一个层面上的?不要在意这些细节……) /**************************** ...

  6. [GRYZ]寒假模拟赛

    写在前面 这是首次广饶一中的OIERS自编自导,自出自做(zuo)的模拟赛. 鉴于水平气压比较低,机(wei)智(suo)的WMY/XYD/HYXZC就上网FQ下海找了不少水(fei)题,经过他们优( ...

  7. poj1741 bzoj2152

    树分治入门 poj1741是男人八题之一,经典的树分治的题目这里用到的是点分治核心思想是我们把某个点i作为根,把路径分为过点i和不过点i先统计过点i这样的路径数,然后在统计其子树中的答案,这样就不断地 ...

  8. CF 121E Lucky Array 【树状数组】

    这个题目的数据感觉不能更水了.从复杂度上计算,肯定有极限数据可以卡掉暴力方法的么. 总之,暴力的做法就是树状数组了,对于区间更新,就挨个更新就是了.当然,判断是否是Lucky Number的话,可以用 ...

  9. SGU 115.Calendar

    连水3道,还能更水么... #include <stdio.h> using namespace std; ] = {, , , , , , , , , , , , }; int n, m ...

随机推荐

  1. a=a+(a++);b=b+(++b);计算顺序,反汇编

    a=a+(a++); 013913BC mov eax,dword ptr [a] 013913BF add eax,dword ptr [a] 013913C2 mov dword ptr [a], ...

  2. P2082 区间覆盖(加强版)

    题目 #include<iostream> #include<algorithm> #include<cstring> using namespace std; s ...

  3. Yarn下分片和分块源代码分析

    public class FileSplit extends InputSplit implements Writable { private Path file; private long star ...

  4. 第42章 电源管理—实现低功耗—零死角玩转STM32-F429系列

    第42章     电源管理—实现低功耗 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.youku.com/fir ...

  5. rnn,lstm and JuergenSchmidhuber

    JuergenSchmidhuber 是瑞士的一位牛人,主要贡献是rnn, lstm. google的deep mind新作,Human-level control through deep rein ...

  6. swiper轮播始终居中active图片

    用的是vue-awesome-swiper 在vue项目中,参数方法与swiper一致.使用场景如下: 左侧小图一共八张,默认显示的是三张,始终保持activeimg在中间,提升用户体验度.swipe ...

  7. iconv for linux(c)

    // code_convert("gb2312","utf-8",inbuf,outbuf,outlen);static int code_convert(co ...

  8. 【杂题总汇】NOIP2013(洛谷P1967) 货车运输

    [洛谷P1967] 货车运输 重做NOIP提高组ing... +传送门-洛谷P1967+ ◇ 题目(copy from 洛谷) 题目描述 A国有n座城市,编号从1到n,城市之间有m条双向道路.每一条道 ...

  9. 前端之jquery函数库

    jquery介绍 jQuery是目前使用最广泛的javascript函数库.据统计,全世界排名前100万的网站,有46%使用jQuery,远远超过其他库.微软公司甚至把jQuery作为他们的官方库. ...

  10. 给网站添加icon图标

    只需制成ico结尾的图片即可