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 ...
随机推荐
- tomcat下获取当前路径的url中含有空格解决方法
参考博文(http://www.360doc.com/content/11/1009/17/4602013_154657565.shtml) web项目发布到Tomcat之后,如果tomcat是安装在 ...
- nefu 903 字符串去星
字符串去星 Problem : 903 Time Limit : 1000ms Memory Limit : 65536K description 有一个字符串(长度小于100),要统计其中有多少个* ...
- 【Machine Learning in Action --4】朴素贝叶斯从个人广告中获取区域倾向
背景:广告商往往想知道关于一个人的一些特定人口统计信息,以便能更好地定向推销广告. 我们将分别从美国的两个城市中选取一些人,通过分析这些人发布的信息,来比较这两个城市的人们在广告用词上是否不同.如果结 ...
- KVM 命令行启动第一台虚拟机
KVM创建第一台虚拟机 1 创建一个镜像 [root@kvm ~]# qemu-img create -f raw /opt/CentOS6.-x86_64.raw 5G Formatting [ro ...
- 使用HttpClient工具类测试WebService接口(soap)
import java.io.ByteArrayInputStream;import java.io.IOException;import java.io.InputStream;import jav ...
- Sping3.0版本+Quartz完成定时任务
----------------------不使用注解在XML中配置完成定时任务---------------------- 1.需要导入的jar包 2.编写我们的定时任务的完成类 3.在Spring ...
- Windows server 2008搭建php运行环境
下载php组件包 首先到http://windows.php.net/download/下载你需要的php版本,这里我下载的是php5.3. 下面解压php组件 包到磁盘上. 安装Microsoft ...
- hdu_4539_郑厂长系列故事——排兵布阵(状压DP|最大团)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4539 题意:中文,不解释 题解:将每一行的状态压缩,然后进行DP,也可以用最大团做.这里我用的DP # ...
- LeetCode OJ 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For e ...
- ecshop 去版权
与官网通信的几个地方: 1,打开admin/templates/index.htm,查找并删除 <frameset rows="0, 0" framespacing=&quo ...