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 ;
}

最新文章

  1. irefox 34的"Manage Search Engine"去哪了
  2. 安卓仿制新浪微博(一)之OAuth2授权接口
  3. java InputStream使用
  4. Android Intent实现页面跳转
  5. 乐在其中设计模式(C#) - 提供者模式(Provider Pattern)
  6. Ubuntu iptables 设置
  7. Android 性能测试——Heap Viewer 工具
  8. width和max-width的用处
  9. 目录导航「深入浅出ASP.NET Core系列」
  10. sqlserver给用户配置存储过程查看权限
  11. ASP.NET MVC+BUI实现表格的操作
  12. requests.get() 的 headers 参数
  13. &lt;Dare To Dream 团队&gt;第二次作业:基于B/S的家教管理系统
  14. C# oracle to_date 日期型 参数传值
  15. 可执行 jar | 到底如何执行
  16. setAttribute()、getAttribute()与ele[attr]与自定义属性
  17. 数组操作方法中的splice()和concat() 以及slice()
  18. linux命令-grep+正则表达式用法
  19. C和指针之学习笔记(1)
  20. makefile之call函数

热门文章

  1. java支持跨平台获取cpuid、主板id、硬盘id、mac地址 (兼容windows、Linux)
  2. cnblog中添加数学公式支持
  3. github上readme.md 格式
  4. javascript数据结构与算法-- 二叉树
  5. Silicon C8051F340之GPIO口配置与使用
  6. Mac Pro 编译安装 Redis-3.2.3
  7. 倾力总结40条常见的移动端Web页面问题解决方案
  8. git 教程(14)--解决冲突
  9. senlin __init__() got an unexpected keyword argument &#39;additional_headers&#39;
  10. screen 常用命令