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. JQuery 过滤选择器 与属性修改的方法演示比较

    文本匹配 在表单输入项里面输入值,根据输入值,点击判断按钮,让对应的复选框选中 <html> <head> <meta http-equiv="Content- ...

  2. Dijkstra&&Floyd

    文章来源:(http://www.cnblogs.com/biyeymyhjob/archive/2012/07/31/2615833.html) (以下内容皆为转载) Dijkstra算法 1.定义 ...

  3. hdu_3501_Calculation 2

    Given a positive integer N, your task is to calculate the sum of the positive integers less than N w ...

  4. JS - 属性描述符各配置的默认值的注意事项

    通过字面量或者obj.x = 1;创建的属性 与 通过Object.defineProperty创建的属性,他们的属性描述符的默认值是不同的,前者都为true,后者都为false.

  5. 路由器基础配置之单臂路由实现vlan间通信

    我们将以上面的拓扑图开始进行配置,目的为设置单臂路由实现vlan间通信,设置4个vlan,pc0,1,2为vlan10 pc3,4,5为vlan20:pc6,7,8为vlan30:server0,1为 ...

  6. PHP 二维数组按某一个键值排序

    一.前言 在某个项目中,需要读取某个文件夹下的所有文件,在本地的 Windows 环境下时,读取出来的二维数组的文件名称和在 Windows 文件夹的文件排序一致, 但是项目上线后,环境为 Linux ...

  7. php COM

    查看php.ini中是否已经开启了com.allow_dcom = true 从php/ext/里面查找一下有没有这个php_com_dotnet.dll这个文件 如果没有网上下载个,一般都会有的吧应 ...

  8. 残留的linux相关笔记

    1. 设置网络环境1) 设置宿主机网络环境#ifconfig eth1 192.168.16.111 2) 设置开发板网络环境>pri>setenv ipaddr 192.168.16.2 ...

  9. Dropping Balls(小球下落)

    紫书P148,例题6-6 Sample Input 4 2 3 4 10 1 2 2 8 128 Sample Output 12 7 512 3 255 这应该不仅仅是一棵完全二叉树,题目中说保证所 ...

  10. 笔记-scrapy与twisted

    笔记-scrapy与twisted Scrapy使用了Twisted作为框架,Twisted有些特殊的地方是它是事件驱动的,并且比较适合异步的代码. 在任何情况下,都不要写阻塞的代码.阻塞的代码包括: ...