Who's in the Middle[HDU1157]
Who's in the Middle
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 16668 Accepted Submission(s):
7471
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.
* Lines 2..N+1:
Each line contains a single integer that is the milk output of one
cow.
output.
INPUT DETAILS: Five cows with milk outputs of 1..5 OUTPUT DETAILS: 1 and 2 are below 3; 4 and 5 are above 3.
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=;i<n;i++)
scanf("%d",&a[i]);
sort(a,a+n);
printf("%d\n",a[n/]);
}
return ;
}
Who's in the Middle[HDU1157]的更多相关文章
- HDU1157 Who's in the Middle
Who's in the Middle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- 代码的坏味道(21)——中间人(Middle Man)
坏味道--中间人(Middle Man) 特征 如果一个类的作用仅仅是指向另一个类的委托,为什么要存在呢? 问题原因 对象的基本特征之一就是封装:对外部世界隐藏其内部细节.封装往往伴随委托.但是人们可 ...
- 【BZOJ-2653】middle 可持久化线段树 + 二分
2653: middle Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 1298 Solved: 734[Submit][Status][Discu ...
- [LintCode] Delete Node in the Middle of Singly Linked List 在单链表的中间删除节点
Implement an algorithm to delete a node in the middle of a singly linked list, given only access to ...
- vertical-align:middle
img style="vertical-align:middle;" src="<%=basePath%>/images/ckpy.png" > ...
- 【leetcode】Sort List (middle)
Sort a linked list in O(n log n) time using constant space complexity. 思路: 用归并排序.设输入链表为S,则先将其拆分为前半部分 ...
- 【leetcode】Reorder List (middle)
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do thi ...
- 【leetcode】Number of Islands(middle)
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...
- 运用vertical:middle 使得元素垂直居中
我要垂直居中我要垂直居中我要垂直居中我要垂直居中我要垂直居中垂直居中垂直居中垂直居中中垂直居中垂直居中 <!-- 第一步:主题元素display:inline-block;第二步:插入辅助元 ...
随机推荐
- 图解JVM的类加载机制(详细版)
注:本文为作者整理和原创,如有转载,请注明出处. 上一篇博文,把JAVA中的Class文件格式用图形的方式画了一下,逻辑感觉清晰多了,同时,也为以后查阅的方便. Class文件只是一种静态格式的二进制 ...
- shell的一些应用场景
列出每个IP的连接数 netstat -n | awk '/^tcp/{print $5}' | awk -F: '!/^::/{print $1}' | sort | uniq -c | sort ...
- FireFox每次访问页面时检查最新版本
FireFox每次访问页面时检查最新版本 浏览器都有自己的缓存机制,作为开发人员,每次js的修改都要清空缓存,显然很不方便.而firefox并没有提供ie那样的设置. 下面的方法就可以非常方便的设置f ...
- Bootstrap学习------按钮
Bootstrap为我们提供了按钮组的样式,博主写了几个简单的例子,以后也许用的到. 效果如下 代码如下 <!DOCTYPE html> <html> <head> ...
- [Head First设计模式]山西面馆中的设计模式——建造者模式
系列文章 [Head First设计模式]山西面馆中的设计模式——装饰者模式 [Head First设计模式]山西面馆中的设计模式——观察者模式 引言 将学习融入生活中,是件很happy的事情,不会感 ...
- [Nhibernate]体系结构
引言 在项目中也有用到过nhibernate但对nhibernate的认识,也存留在会用的阶段,从没深入的学习过,决定对nhibernate做一个系统的学习. ORM 对象-关系映射(OBJECT/R ...
- golang笔记——struct
1.定义一个结构体 type User struct { userid int username string password string } 2.初始化一个结构体 有两种情况,一是得到结构体的对 ...
- 大熊君大话NodeJS之------(Url,QueryString,Path)模块
一,开篇分析 这篇文章把这三个模块拿来一起说,原因是它们各自的篇幅都不是很长,其次是它们之间存在着依赖关系,所以依次介绍并且实例分析.废话不多说了,请看下面文档: (1),"Url模块&qu ...
- hibernate4学习
1. 安装hibernatetools插件 2. 这个是篇测试文档 来自为知笔记(Wiz)
- PHP如何判断一个gif图片是否为动画?
首先想到的是用getimagesize()看看type,发现都是gif. 然后想gif动画是gif89格式的,发现文件开头是gif89,但是很多透明图片也是用的gif89格式. 看来必须分析文件的祯了 ...