1753: [Usaco2005 qua]Who's in the Middle
1753: [Usaco2005 qua]Who's in the Middle
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 290 Solved: 242
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
2
4
1
3
5
INPUT DETAILS:
Five cows with milk outputs of 1..5
Sample Output
OUTPUT DETAILS:
1 and 2 are below 3; 4 and 5 are above 3.
HINT
Source
题解:难以想象这样的题目居然是usaco金组的= =,汗。。
其实直接排序就好啦,但是这样子太没意思了,于是来个简单的小优化(程序如下,很清晰,相信你们一定看得懂)
/**************************************************************
Problem:
User: HansBug
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/ var
i,j,k,l,m,n,x,y:longint;
a:array[..] of longint;
procedure sort(l,r:longint);
var i,j,x,y:longint;
begin
if (l>m) or (r<m) then exit; //here!!!^_^
i:=l;j:=r;x:=a[(l+r) div ];
repeat
while a[i]<x do inc(i);
while a[j]>x do dec(j);
if i<=j then
begin
y:=a[i];a[i]:=a[j];a[j]:=y;
inc(i);dec(j);
end;
until i>j;
if i<r then sort(i,r);
if l<j then sort(l,j);
end; begin
readln(n);m:=(+n) div ;
for i:= to n do readln(a[i]);
sort(,n);
writeln(a[m]);
readln;
end.
1753: [Usaco2005 qua]Who's in the Middle的更多相关文章
- bzoj 1753: [Usaco2005 qua]Who's in the Middle【排序】
--这可能是早年Pascal盛行的时候考排序的吧居然还是Glod-- #include<iostream> #include<cstdio> #include<algor ...
- bzoj1753 [Usaco2005 qua]Who's in the Middle
Description FJ is surveying his herd to find the most average cow. He wants to know how much milk th ...
- BZOJ1754: [Usaco2005 qua]Bull Math
1754: [Usaco2005 qua]Bull Math Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 374 Solved: 227[Submit ...
- bzoj1751 [Usaco2005 qua]Lake Counting
1751: [Usaco2005 qua]Lake Counting Time Limit: 5 Sec Memory Limit: 64 MB Submit: 168 Solved: 130 [ ...
- 1755: [Usaco2005 qua]Bank Interest
1755: [Usaco2005 qua]Bank Interest Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 187 Solved: 162[Su ...
- 1754: [Usaco2005 qua]Bull Math
1754: [Usaco2005 qua]Bull Math Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 398 Solved: 242[Submit ...
- 1751: [Usaco2005 qua]Lake Counting
1751: [Usaco2005 qua]Lake Counting Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 190 Solved: 150[Su ...
- bzoj3384[Usaco2004 Nov]Apple Catching 接苹果*&&bzoj1750[Usaco2005 qua]Apple Catching*
bzoj3384[Usaco2004 Nov]Apple Catching 接苹果 bzoj1750[Usaco2005 qua]Apple Catching 题意: 两棵树,每分钟会从其中一棵树上掉 ...
- BZOJ 1754: [Usaco2005 qua]Bull Math
Description Bulls are so much better at math than the cows. They can multiply huge integers together ...
随机推荐
- easyUI 添加排序到datagrid
http://www.cnblogs.com/javaexam2/archive/2012/08/10/2632645.html
- css块级标签,行内标签,行内块标签的转换(2)
css块级标签,行内标签,行内块标签的转换 版权声明 本文原创作者:雨点的名字 作者博客地址:https://home.cnblogs.com/u/qdhxhz/ 在基础1中,我详细讲 ...
- 告别被拒,如何提升iOS审核通过率(下篇)——应用内容检查大法与提审资源检查大法
WeTest 导读 之前的<告别被拒,如何提升iOS审核通过率(上篇)>分享了客户端检查的相关要点,本篇会给大家介绍有关应用内容的检查项和提审资源相关检查项要点. 应用内容检查大法 苹果对 ...
- Hadoop学习笔记-003-CentOS_6.5_64_设置ssh免密码登录
参考:http://blog.csdn.net/u010270403/article/details/51444677 虚拟机中共五个centos系统,每个系统有两个用户root和hadoop:cdh ...
- 私有云存储搭建(owncloud)
第一步.搭建LAMP(基于linux7.1.1503) 1 配置yum(网络加本地,下面为网络) [vault.centos.org_7.1.1503_os_x86_64_] name=added f ...
- 设计社区Dribbble VS. Bēhance,你选谁?
Behance和Dribbble都是主流的设计作品分享平台,为广大设计师同胞们带来了莫大的便利,所以很多设计师通常两个社区都会关注.很多设计师在展示个人信息的时候,通常也会把这两个平台的链接放到个人资 ...
- 通过判断cookie过期方式向Memcached中添加,取出数据(Java)
应用场景:在数据驱动的web开发中,经常要重复从数据库中取出相同的数据,这种重复极大的增加了数据库负载.缓存是解决这个问题的好办法.但是ASP.NET中的虽然已经可以实现对页面局部进行缓存,但还是不够 ...
- Google HTML/CSS 编码规范
Google HTML/CSS 规范 本文介绍了 Google 推荐的 HTML 和 CSS 编写格式规范,以建立良好的个人编码习惯. 1.通用样式规范 省略图片.样式.脚本以及其他媒体文件 URL ...
- react native 运行项目下载gradle慢的解决办法
react-native run-android 慢 React-native run-Android中需要下载https://services.gradle.org/distributions/gr ...
- 从C#到TypeScript - 变量
总目录 从C#到TypeScript - 类型 从C#到TypeScript - 高级类型 从C#到TypeScript - 变量 从C#到TypeScript - 接口 从C#到TypeScript ...