SDAU课程练习--problemQ(1016)
题目描述
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
题目大意
十足的水题,排序后找出中位数即可
AC代码
#include<iostream>#include<stdio.h>#include<algorithm>using namespace std;int a[10000];int main(){//freopen("date.in", "r", stdin);//freopen("date.out", "w", stdout);int N;while (~scanf("%d", &N)){//memset(a, 0, 10000 * sizeof(int));for(int i = 0; i < N; i++){cin>>a[i];}sort(a, a + N);cout << a[(N + 1) / 2-1];}}
SDAU课程练习--problemQ(1016)的更多相关文章
- SDAU课程练习--problemG(1006)
题目描述 Problem Description The highest building in our city has only one elevator. A request list is m ...
- SDAU课程练习--problemO(1014)
题目描述 Before bridges were common, ferries were used to transport cars across rivers. River ferries, u ...
- SDAU课程练习--problemB(1001)
题目描述 There is a pile of n wooden sticks. The length and weight of each stick are known in advance. T ...
- SDAU课程练习--problemA(1000)
题目描述 The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape i ...
- SDAU课程练习--problemC
题目描述 Here is a famous story in Chinese history. "That was about 2300 years ago. General Tian Ji ...
- SDAU课程练习--problemE
problemE 题目描述 "今年暑假不AC?" "是的." "那你干什么呢?" "看世界杯呀,笨蛋!" "@ ...
- sicily 1016. 排队接水--课程作业
1016. 排队接水 Time Limi ...
- 20165319 2017-2018-2《Java程序设计》课程总结
一.每周作业链接汇总 预备作业一:我期望的师生关系 20165319 我所期望的师生关系 预备作业二:学习基础和C语言基础调查 20165319 学习基础和C语言基础调查 摘要: 技能学习经验 c语言 ...
- .NET 提升教育 第一期:VIP 付费课程培训通知!
为响应 @当年在远方 同学的建议,在年前尝试进行一次付费的VIP培训. 培训的课件:点击下载培训周期:10个课程左右,每晚1个半小时培训价格:1000元/人.报名方式:有意向的请加QQ群:路过秋天.N ...
随机推荐
- 朋友遇到过的t厂面试题
朋友遇到过的t面试题 leetcode160 找链表交点 leetcode206 反转链表
- Java "==" 和 "equals" 和 "" 问题
//equals()方法出现的问题 String a="testd"; String b="testd"; String c=new String(" ...
- 2015 Multi-University Training Contest 7
1001 Game On the Tree 1002 Tree Maker 1003 Hotaru's problem Manacher处理好p数组. 暴力举一下公共串即可. # include &l ...
- 【python问题系列--2】脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level
缩进错误,此错误,最常见的原因是行之间没有对齐. 参考:http://www.crifan.com/python_syntax_error_indentationerror/comment-page- ...
- 关于oracle数据库(10)函数
分析函数,用于统计排名 语法:函数名() over(order by 排序字段 asc | desc) row_number() 无论值是否相等,生成连续的行号 -- 1,2,3,4, select ...
- AltiumDesigner14绘制四层板设置
1,快捷键(O+K)进入板层设置界面: 2,选择AddLayer,里边有两个选项(add layer(添加信号层)||add internal plane(增加平面)) 四层板的话一般层次的划分是t ...
- c#设计模式-单例模式(面试题)
c#设计模式-单例模式 单例模式三种写法: 第一种最简单,但没有考虑线程安全,在多线程时可能会出问题, public class Singleton { private static Singleto ...
- 项目管理实践【三】每日构建【Daily Build Using CruiseControl.NET and MSBuild】
在上一篇项目管理实践教程二.源代码控制[Source Control Using VisualSVN Server and TortoiseSVN]中我们已经讲解了如何使用TortoiseSVN和Vi ...
- java代理的深入浅出(一)-Proxy
java代理的深入浅出(一)-Proxy 1.什么是代理 代理模式是常用的java设计模式,他的特征是代理类与委托类有同样的接口,代理类主要负责为委托类预处理消息.过滤消息.把消息转发给委托类,以及事 ...
- RIDE的使用
在RIDE中,CTRL + R 自动打开report.html , CTRL + L 自动打开 log.html