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 ...
随机推荐
- 响应HttpServletResponse
可以使用HttpServletResponse来对浏览器进行响应,大部分情况下,会使用setContentType()设置响应类型,使用getWriter()取得PrintWriter对象,而后使用P ...
- PHP + Memcache 实现Session共享
一.安装Memcache和PHP扩展 Windows下的Memcache安装:1. 下载memcache的windows稳定版,解压放某个盘下面,比如在c:\memcached2. 在终端(也即cmd ...
- 在Eclipse中提交SVN项目的时候注意提交项目信息
提交项目的时候,注意提交.classpath,.project和.settings文件夹: 这些是项目的信息,别人下载的时候才能正确显示为Eclipse项目:
- 用php 进行对文件的操作 (下)
继续来说文件操作 新建一个文件夹或是删除一个文件夹,并不是只有右击一种方法,还可以用代码来操作 先来看没有运行代码之前的目录下有哪些文件 点击运行代码后再来看有没有增加名为aa的文件夹 添加成功 再来 ...
- java Runtime类
public class Test { public static void main(String[] args) throws UnsupportedEncodingException { Run ...
- Js获取复选框checkbox的值
var emps= $("input[name='emp']:checked"); var employee= ""; emps.each(function() ...
- 《微信小程序七日谈》- 第六天:小程序devtool隐藏的秘密
<微信小程序七日谈>系列文章: 第一天:人生若只如初见: 第二天:你可能要抛弃原来的响应式开发思维: 第三天:玩转Page组件的生命周期: 第四天:页面路径最多五层?导航可以这么玩: 第五 ...
- 用虚拟 router 连通 subnet - 每天5分钟玩转 OpenStack(141)
Neutron Routing 服务提供跨 subnet 互联互通的能力.例如前面我们搭建了实验环境: cirros-vm1 172.16.100.3 vlan100 cirr ...
- Spring Boot踩坑之路一
Takes an opinionated view of building production-ready Spring applications. Spring Boot favors conve ...
- 程序员的一生时间90%是用在编程上,而剩余的10%是活在世界上。刚进CSDN的博客看到这么句话
程序员的一生时间90%是用在编程上,而剩余的10%是活在世界上. 而自己呢?是个程序员呢还是个业余玩家!