Who's in the Middle 分类: POJ 2015-06-12 19:45 11人阅读 评论(0) 收藏
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 34155 | Accepted: 19875 |
Description
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
* Lines 2..N+1: Each line contains a single integer that is the milk output of one cow.
Output
Sample Input
5
2
4
1
3
5
Sample Output
3
不说了,看代码
#include <cstdio>
#include <string.h>
#include <cmath>
#include <iostream>
#include <algorithm>
#define WW freopen("output.txt","w",stdout)
using namespace std;
const int Max=11000;
int a[Max];
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+n);
printf("%d\n",a[n/2]);
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
Who's in the Middle 分类: POJ 2015-06-12 19:45 11人阅读 评论(0) 收藏的更多相关文章
- Robot Motion 分类: POJ 2015-06-29 13:45 11人阅读 评论(0) 收藏
Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11262 Accepted: 5482 Descrip ...
- 迷之节约 分类: sdutOJ 最小生成树 2015-06-24 19:10 10人阅读 评论(0) 收藏
迷之节约 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 FF超级有钱,最近又买了n个(1 <= n <= 300)小岛,为 ...
- Hdu 1506 Largest Rectangle in a Histogram 分类: Brush Mode 2014-10-28 19:16 93人阅读 评论(0) 收藏
Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- 二分图匹配 分类: ACM TYPE 2014-10-01 19:57 94人阅读 评论(0) 收藏
#include<cstdio> #include<cstring> using namespace std; bool map[505][505]; int n, k; bo ...
- Can you find it? 分类: 二分查找 2015-06-10 19:55 5人阅读 评论(0) 收藏
Description Give you three sequences of numbers A, B, C, then we give you a number X. Now you need t ...
- iOS开发~CocoaPods使用详细说明 分类: ios相关 2015-04-01 16:45 68人阅读 评论(0) 收藏
iOS开发-CocoaPods使用详细说明 一.概要 iOS开发时,项目中会引用许多第三方库,CocoaPods(https://github.com/CocoaPods/CocoaPods)可以用来 ...
- 菊花加载第三方--MBprogressHUD 分类: ios技术 2015-02-05 19:21 120人阅读 评论(0) 收藏
上次说到了网络请求AFN,那么我们在网络请求的时候,等待期间,为了让用户不认为是卡死或程序出错,一般都会放一个菊花加载,系统有一个菊花加载类叫UIProgressHUD.但是我今天要说的是一个替代它的 ...
- c++map的用法 分类: POJ 2015-06-19 18:36 11人阅读 评论(0) 收藏
c++map的用法 分类: 资料 2012-11-14 21:26 10573人阅读 评论(0) 收藏 举报 最全的c++map的用法 此文是复制来的0.0 1. map最基本的构造函数: map&l ...
- Power Strings 分类: POJ 串 2015-07-31 19:05 8人阅读 评论(0) 收藏
Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practice POJ ...
随机推荐
- Java-NIO-Selector
扩展阅读: Java NIO类库Selector机制解析(上) Java NIO类库Selector机制解析(下) Java NIO的选择器 三个重要的类: 1,Selector 选择器,完成主要的选 ...
- Silverlight TabItem选中,未选中样式设置
<Application.Resources> <LinearGradientBrush x:Key="TabItemBackground" EndPoint=& ...
- 隐藏ipad/ip顶部状态栏
在GameViewController.swift中重载prefersStatusBarHidden方法,返回true override func prefersStatusBarHidden() - ...
- PostgreSQL应用相关问题解决
PostgreSQL中是否区分聚簇索引与非聚簇索引的问题? 答:PostgreSQL中区分聚簇索引与非聚簇索引. 示例如下: 创建聚族索引: CREATE INDEX test_ind ON yy ( ...
- Lintcode: Matrix Zigzag Traversal
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in ZigZag-or ...
- Java基础(38):Calendar类的应用(优于Date类)
Calendar 类的应用 Date 类最主要的作用就是获得当前时间,同时这个类里面也具有设置时间以及一些其他的功能,但是由于本身设计的问题,这些方法却遭到众多批评,不建议使用,更推荐使用 Calen ...
- 使用UIL(Universal-Image-Loader)异步加载图片
概要: Android-Universal-Image-Loader是一个开源的UI组件程序,该项目的目的是实现可重复使用的异步图像加载.缓存和显示.所以,如果你的程序里需要这个功能的话,使用它,因为 ...
- html5新增全局属性
data-* 如:data-type,data-role等 hidden <div hidden></div> 隐藏该div spellcheck <textarea ...
- fnd_profile.value('AFLOG_ENABLED')的取值 和配置文件相关SQL
SELECT * FROM FND_PROFILE_OPTIONS_VL TT WHERE TT.PROFILE_OPTION_NAME LIKE '%AFLOG%' FND:启用调试日志 详细的参考 ...
- stdlib 头文件
stdlib 头文件即standard library标准库头文件.stdlib.h里面定义了五种类型.一些宏和通用工具函数. 类型例如size_t.wchar_t.div_t.ldiv_t和lldi ...