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;第二步:插入辅助元 ...
随机推荐
- mysql备份脚本,每天执行一次全量备份,三次增量备份
线上一个小业务的mysql备份 全量备份 #!/bin/bash #crete by hexm at -- #scripte name : full_backup.sh #descriptioni : ...
- Web前端开发高手进阶
Web前端开发高手进阶 js框架+Ajax技术01.初识javascript及其语言基础(一)02.初识javascript及其语言基础(二)03.初识javascript及其语言基础(三)及js原 ...
- pycloudtag 标签云
原创,转载请标明 QQ:231469242 # -*- coding: utf-8 -*- """Python3.0 Created on Sat Nov 26 08:5 ...
- 10月30日下午 PHP精确查询(模糊查询、模糊+关键字共同查询)
1.一个条件的模糊查询 <body> <br /> <form action="main.php" method="post"&g ...
- SQLPROMPT5.3对各种加密对象的解密测试
SQLPROMPT5.3对各种加密对象的解密测试 测试环境: SQL2005个人开发者版 SP4 SQLPROMPT版本:5.3.8.2 视图 CREATE VIEW aa WITH ENCRYPTI ...
- 浅谈JavaScript中的defer,async
引言 开始重读<<JavaScript高级程序设计>>一书,看到关于JavaScript中关于defer.async的部分.网上查询了点资料,觉得蛮好的.现在总结下. defe ...
- vue2.0学习(二)
1.关于模板渲染,当需要渲染多个元素时可以 <ul> <template v-for="item in items"> <li>{{ item. ...
- word20161210
gateway / 网关 gateway account / 网关帐户 Gateway Service for NetWare / NetWare 网关服务 GDI objects / GDI 对象 ...
- 2016年11月28日--ADO.Net 增、删、改、查
数据访问 对应命名空间:System.Data.SqlClient; SqlConnection:连接对象SqlCommand:命令对象SqlDataReader:读取器对象 CommandText: ...
- 2015安徽省赛 G.你来擒孟获
http://xcacm.hfut.edu.cn/problem.php?id=1211 SPFA模板题目 最短路变种,从起点终点各找一次最短路相加 #include<iostream> ...