Who's in the Middle

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 16668    Accepted Submission(s):
7471

Problem 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.

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

Who's in the Middle[HDU1157]的更多相关文章

  1. HDU1157 Who&#39;s in the Middle

    Who's in the Middle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  2. 代码的坏味道(21)——中间人(Middle Man)

    坏味道--中间人(Middle Man) 特征 如果一个类的作用仅仅是指向另一个类的委托,为什么要存在呢? 问题原因 对象的基本特征之一就是封装:对外部世界隐藏其内部细节.封装往往伴随委托.但是人们可 ...

  3. 【BZOJ-2653】middle 可持久化线段树 + 二分

    2653: middle Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 1298  Solved: 734[Submit][Status][Discu ...

  4. [LintCode] Delete Node in the Middle of Singly Linked List 在单链表的中间删除节点

    Implement an algorithm to delete a node in the middle of a singly linked list, given only access to ...

  5. vertical-align:middle

    img style="vertical-align:middle;" src="<%=basePath%>/images/ckpy.png" > ...

  6. 【leetcode】Sort List (middle)

    Sort a linked list in O(n log n) time using constant space complexity. 思路: 用归并排序.设输入链表为S,则先将其拆分为前半部分 ...

  7. 【leetcode】Reorder List (middle)

    Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do thi ...

  8. 【leetcode】Number of Islands(middle)

    Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...

  9. 运用vertical:middle 使得元素垂直居中

    我要垂直居中我要垂直居中我要垂直居中我要垂直居中我要垂直居中垂直居中垂直居中垂直居中中垂直居中垂直居中   <!-- 第一步:主题元素display:inline-block;第二步:插入辅助元 ...

随机推荐

  1. thinkphp分页二,分装到funciton.php

    function.php代码 <?php /* 全局分页 * $table 数据表名 * $order 排序 * $pagesize 每页显示N个 * $where 查询条件 * $rollPp ...

  2. Docker数据持久化与容器迁移

    上节讲到当容器运行期间产生的数据是不会在写镜像里面的,重新用此镜像启动新的容器就会初始化镜像,会加一个全新的读写入层来保存数据.如果想做到数据持久化,Docker提供数据卷(Data volume)或 ...

  3. 【转】Controllers and Routers in ASP.NET MVC 3

    Controllers and Routers in ASP.NET MVC 3 ambilykk, 3 May 2011 CPOL 4.79 (23 votes) Rate: vote 1vote ...

  4. JAVA关键字与保留字说明及使用

    1.abstract 2.boolean 3.break 4.byte 5.case 6.catch 7.char 8.class 9.continue 10.default 11.do 12.dou ...

  5. 【荐】如何正确理解PHP之include,include_once,require,require_once等包含作用域

    我们为大家总结的PHP include作用域的问题包括:PHP include 变量作用域和函数.类的作用域等方面的问题.希望对大家有所帮助. 很多程序员在使用PHP语言进行实际编程时,通常只会关注P ...

  6. MySQL Cluster在线添加数据节点

    增加或减少数据节点的数量和 NoOfReplicas(即副本数,通过管理节点的config.ini配置文件来设置)有关,一般来说NoOfReplicas是2,那么增加或减少的数量也应该是成对的,否则要 ...

  7. 去除ios系统a标签点击时的灰色背景

    使用图片作为a标签的点击按钮时,当触发touchstart的时候,往往会有一个灰色的背景,想要去掉的话可以用下面这种方式 a,a:hover,a:active,a:visited,a:link,a:f ...

  8. 刷了MIUI的手机在OSX下连接USB调试的方法

    OSX下默认连接不上小米手机或者刷了MIUI的手机. 办法是: 1, 关于本机->系统报告->USB,在其中找到手机设备,然后查看其厂商ID,复制. 2,控制台执行下面这个命令,把其中的0 ...

  9. filedownload

    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE web-app PUBLIC "-/ ...

  10. (2016弱校联盟十一专场10.3) B.Help the Princess!

    题目链接 宽搜一下就行. #include <iostream> #include<cstdio> #include<cstring> #include<qu ...