Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:其实本体不是很水。

Posted by cz908640443 at 2010-10-25 16:12:19 on Problem 2388
In Reply To:其实本体不是很水。 Posted by:baicaitest at 2009-08-11 13:41:53
> 看排行榜,牛们0ms的代码都很长。难道是什么顺序统计算法?有哪位0ms的贴下代码学习下?
var
  i,n:longint;
  a:array[1..10000]of longint;
procedure sort(l,r:longint);
  var
    i,j,x,y:longint;
  begin
    i:=l;j:=r;x:=a[(l+r) div 2];
    repeat
      while a[i]<x do inc(i);
      while x<a[j] do dec(j);
      if not(i>j)
         then begin
           y:=a[i];a[i]:=a[j];a[j]:=y;
           inc(i);j:=j-1;
         end;
    until i>j;
    if l<j then sort(l,j);
    if i<r then sort(i,r);
  end;
begin
  readln(n);
  for i:=1to n do readln(a[i]);
  sort(1,n);
  writeln(a[(1+n)div 2]);
end.
水水的代码

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator