课程练习一 Problem Q id 1016
来源:互联网 发布:如何优化兵团经济结构 编辑:程序博客网 时间:2024/05/16 12:40
*题目编号 Problem Q id: 1016
*简单题意 :求一组数中大于一半数,小于等于另一半数的数
*解题思路 输入,排序,输出第a[n-1]/2 的值
*感想:终于碰到一个简单题了
*AC代码
# include<stdio.h>
# include<algorithm>
using namespace std;
int main()
{
int N,a[10001];
scanf("%d",&N);
for(int i=0;i<N;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+N);
printf("%d",a[(N-1)/2]);
return 0;
}
Problem Q
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)
Total Submission(s) : 88 Accepted Submission(s) : 49
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.
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<br><br>* 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
Statistic |Submit | Back
0 0
- 课程练习一 Problem Q id 1016
- 课程练习一-Problem Q
- 2016SDAU课程练习一Problem Q
- 课程练习一 Problem G id:1006
- 课程练习一 Problem B id 1001
- 课程练习一 Problem I id: 1008
- 课程练习一 Problem M id: 1012
- 课程练习一 Problem C id: 1002
- 课程练习一 Problem F id: 1005
- 2016SDAU课程练习一1016Q
- 课程练习一Problem F
- 课程练习一-Problem G
- 课程练习一Problem M
- 2016SDAU课程练习三1017 Problem Q
- 课程练习一problemD id:1004
- 课程练习一Problem A 搬桌子
- 课程练习一Problem E 电视节目
- 2016SDAU课程练习一Problem G
- devstack centos7.2安装笔记
- python,针对所有邮件的自由收发。(例子,QQ发给任何邮箱)
- MTK6.0 spi驱动使用
- hdu2059 龟兔赛跑(DP)
- Android中签名机制详细解释
- 课程练习一 Problem Q id 1016
- 二分查找
- 类选择器class词列表的问题
- android6.0 se问题
- PHP数组的相关处理函数1
- java课堂练习,反射
- OpenLayers 3+Geoserver+PostGIS实现点击查询
- 分布式系统几种典型一致性算法简述
- hdu2064 汉诺塔III