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 ...
随机推荐
- mysql之inner join 和left join/right join
left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录 right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录inner join(等值连接) 只 ...
- LeetCode OJ 42. Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...
- 【FBA】SharePoint 2013自定义Providers在基于表单的身份验证(Forms-Based-Authentication)中的应用
//http://www.cnblogs.com/OceanEyes/p/custom-provider-in-sharepoint-2013-fba-authentication.html 由于项目 ...
- Developing a Custom Membership Provider from the scratch, and using it in the FBA (Form Based Authentication) in SharePoint 2010
//http://blog.sharedove.com/adisjugo/index.php/2011/01/05/writing-a-custom-membership-provider-and-u ...
- javascript点击焦点图
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 使用gulp构建nodejs,你只需要记住5个函数
gulp gulp是一个nodejs的streaming构建工具,所谓的streaming大致意思就是把构建流程想成一个个链接的管道(pipe). 为什么要这样做呢? 要解释原因,就不得不提到unix ...
- 背包问题matlab程序
clearclca=0.95k=[5;10;13;4;3;11;13;10;8;16;7;4];k=-k;d=[2;5;18;3;2;5;10;4;11;7;14;6];restriction=46; ...
- php fsockopen例子
<?php /* * 短信相关api */ class Webcall { protected $VCC_CODE; //api的账号 protected $password; //api的密码 ...
- 艰辛五天:Ubuntu14.04+显卡驱动+cuda+Theano环境安装过程
题记:从一开始不知道显卡就是GPU(虽然是学计算机的,但是我真的不知道…脑残如我也是醉了),到搞好所有这些环境前后弄了5天时间,前面的买显卡.装显卡和装双系统见另一篇博客装显卡.双系统,这篇主要记录我 ...
- js或jquery实现图片轮播
如: 1.//3个div的统一class = 'div' var index =0; //3秒轮播一次 var timer = setInterval(function(){ index = ...