poj 2388 Who's in the Middle
来源:互联网 发布:河南千百知有限公司 编辑:程序博客网 时间:2024/06/05 05:25
Who's in the Middle
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 38442 Accepted: 22325
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.
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.
* 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
524135
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.
Five cows with milk outputs of 1..5
OUTPUT DETAILS:
1 and 2 are below 3; 4 and 5 are above 3.
Source
USACO 2004 November
排好序后输出中间值;
#include<iostream>#include<algorithm>#include<cstdio>#include<string>#include<cstring>int s[10001];using namespace std;int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;++i) { scanf("%d",&s[i]); } sort(s+1,s+1+n); printf("%d\n",s[n/2+1]); return 0;}
0 0
- POJ--2388 Who's in the Middle
- poj 2388 Who's in the Middle
- POJ-2388 who's in the middle
- poj-2388 Who's in the Middle
- poj 2388 Who's in the Middle
- POJ 2388 Who's in the Middle
- poj 2388 Who's in the Middle
- POJ 2388 Who's in the Middle
- Poj 2388 Who's in the Middle
- POJ 2388 Who's in the Middle
- POJ 2388 Who's in the Middle
- poj 2388 Who's in the Middle
- POJ-2388-Who's in the Middle
- poj 2388 Who's in the Middle
- POJ 2388 Who's in the Middle
- poj 2388 Who's in the Middle
- Who's in the Middle(poj 2388)
- POJ 2388:Who's in the Middle
- 报菜名—郭德纲
- UVa 400 打印列优先表
- COMPOSITE(组合模式)
- 安卓控件点击动画(点击后产生波纹效果)
- Mybatis系列目录篇
- poj 2388 Who's in the Middle
- PAT-天梯赛-L1-019. 谁先倒
- TCP/IP的流量控制与拥塞控制机制
- 转载:QQ登录界面
- html (1)
- JAVA 对象引用,以及对象赋值
- 【Effective C++】为类设计new_handler
- Python机器学习开发环境搭建和GraphLab Create安装
- -------------GetObject详解