MiYu原创, 转帖请注明 : 转载自 ______________白白の屋  

题目地址:

http://acm.hdu.edu.cn/showproblem.php?pid=1157

题目描述:

Who's in the Middle

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

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.

水题,  直接代码 :

/*

MiYuÔ­´´, תÌûÇë×¢Ã÷ : תÔØ×Ô ______________°×°×¤ÎÎÝ

http://www.cnblog.com/MiYu

Author By : MiYu

Test      : 1

Program   : 1157

*/

#include <iostream>

#include <algorithm>

using namespace std;

int cow[10010];

int main ()

{

int N;

while ( cin >> N ){

for ( int i = 0; i < N; ++ i ) cin >> cow[i];

sort ( cow, cow + N );

cout << cow[N/2] << endl;

}

return 0;

}

转载于:https://www.cnblogs.com/MiYu/archive/2010/09/04/1818237.html

HDOJ 1157 HDU 1157 Who's in the Middle ACM 1157 IN HDU相关推荐

  1. HDOJ HDU 2080 夹角有多大II ACM 2080 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址:          http://acm.hdu.edu.cn/showproblem.php?pid=2080 ...

  2. HDOJ 2199 HDU 2199 Can you solve this equation? ACM 2199 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址:          http://acm.hdu.edu.cn/showproblem.php?pid=2199 ...

  3. HDOJ 1874 HDU 1874 畅通工程续 ACM 1874 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址:          http://acm.hdu.edu.cn/showproblem.php?pid=1874 ...

  4. HDOJ 1213 HDU 1213 How Many Tables ACM 1213 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址:          http://acm.hdu.edu.cn/showproblem.php?pid=1213 ...

  5. HDOJ 1016 HDU 1016 Prime Ring Problem ACM 1016 IN HDU

    题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=1016 题目描述: Prime Ring Problem Time Limit: 4000/2000 ...

  6. HDOJ 1253 HDU 1253 胜利大逃亡 ACM 1253 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋   题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=1253 题目描述: ...

  7. HDOJ HDU 1106 排序 ACM 1106 IN HDU

    //MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址 :             http://acm.hdu.edu.cn/showproblem.php?pi ...

  8. HDOJ HDU 2058 The sum problem ACM 2058 IN HDU

    //MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址 :          http://acm.hdu.edu.cn/showproblem.php?pid=2 ...

  9. HDOJ HDU 1709 The Balance ACM 1709 IN HDU

    //MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址 :          http://acm.hdu.edu.cn/showproblem.php?pid=1 ...

最新文章

  1. 在app中从下向上滑动,以找到不在默认第一页的元素
  2. DataSet读写xml文件
  3. centos7下发邮件给自己的QQ邮箱
  4. 安利 19 个程序员可以接私活的平台,你有技术就有钱
  5. 360测网速服务器维护,360网速测试器还你真实网速 提供专门维护服务
  6. 通信标准2之PUSCH非动态传输 Configured Grant Type 1 和 Type 2
  7. 英国高中A-Level和IB课程介绍
  8. 程序员:如何优雅的写出好代码?
  9. 博弈论:帕累托最优与纳什均衡的联系和区别
  10. bzGhost打造跨平台即时聊天软件之专栏介绍
  11. 零售行业新渠道,效率居然这么高?
  12. 【Linux vim 入门及渐进过程2 - vim 常用插件配置】
  13. Linux驱动移植USB网卡r8156驱动(详细)总结
  14. IT行业专业术语_其他(学习笔记)
  15. 发现个下载Sailfish OS源码的地方
  16. 海康威视(HIKViSION)2009年校园招聘笔试题-杭州(2)
  17. 「微信小程序」|开发常用事例(六)
  18. 用php搭建公众号服务器,如何快速给自己的微信公众号搭建自己的后台服务端
  19. 使用PWM信号实现呼吸灯(IDE+Protuse)
  20. c语言解密pdf,C语言设计-英文加密解密系统资料.pdf

热门文章

  1. 浅显易懂 Makefile 入门 (03)— 目标文件搜索(VPATH 和 vpath 的区别和使用)、隐含规则
  2. Docker学习(四)-----Docker容器常用命令
  3. 3 用python进行OpenCV实战之画图(直线,矩形,圆形)
  4. windows阿里云服务器配置
  5. java转python
  6. 自然语言处理课程(二):Jieba分词的原理及实例操作
  7. LeetCode简单题之数组的度
  8. TVM实现hardware backend
  9. 华为计算平台MDC810发布量产
  10. 自动驾驶平台,阵营, 主要传感器与场景联系