poj2388 排序
来源:互联网 发布:北京久其软件 编辑:程序博客网 时间:2024/06/01 09:39
Who's in the Middle
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 35246 Accepted: 20582
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>using namespace std;int a[10050];int main(){int n;while(cin>>n){for(int i=0;i<n;i++)cin>>a[i];sort(a,a+n);cout<<a[n/2]<<endl;}}
0 0
- poj2388 排序
- poj2388排序
- poj2388 水题 各种排序
- poj2388(堆排序)
- poj2388排序中位数
- POJ2388-排序水题
- poj2388快速排序
- POJ2388简单排序
- poj2388 快速排序 模板题
- poj2388解题报告(排序)
- poj2388
- POJ2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- OpenStack点滴积累1--Url映射的实现
- [HTML] CSS + JS 多级下拉菜单
- 如何计算时间复杂度
- css兼容问题总结
- 华为OJ(四则运算)
- poj2388 排序
- B\S备忘录26——windows下的mysql cluster搭建
- POJ 1061 青蛙的约会
- 黑马程序员----面向对象
- Matlab中函数句柄@的作用及介绍
- 获取Android数据存放路径
- java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
- LeetCode(4)Median of Two Sorted Arrays
- poj2299 查找逆序数 归并