讨论 / 水
maxwzh 2010-07-23 01:12:00
点我顶贴 收藏 删除
状态: Accepted

测评机: Xeond[6]

得分: 100分

提交日期: 2010-7-23 16:11:00

有效耗时: 3625毫秒

测试结果1: 通过本测试点|有效耗时219ms

测试结果2: 通过本测试点|有效耗时156ms

测试结果3: 通过本测试点|有效耗时157ms

测试结果4: 通过本测试点|有效耗时218ms

测试结果5: 通过本测试点|有效耗时250ms

测试结果6: 通过本测试点|有效耗时532ms

测试结果7: 通过本测试点|有效耗时531ms

测试结果8: 通过本测试点|有效耗时469ms

测试结果9: 通过本测试点|有效耗时515ms

测试结果10: 通过本测试点|有效耗时578ms

提交代码: view sourceprint?01.program fruit;

02.var n,i,s,t,j,k:longint;

03.

a:array[1..10000] of longint;

04.

procedure quicksort(l,r:longint);

05.

var i,j,x,t:longint;

06.

begin

07.

i:=l; j:=r; x:=a[(l+r)div 2];

08.

repeat

09.

while a[i]<x do inc(i);

10.

while a[j]>x do dec(j);

11.

if (a[i]>=a[j])and(i<=j) then begin

12.

t:=a[i]; a[i]:=a[j]; a[j]:=t;

13.

inc(i); dec(j);

14.

end;

15.

until i>j;

16.

if j>l then quicksort(l,j);

17.

if i<r then quicksort(i,r);

18.end;

19.begin

20.

readln (n);

21.

for i:=1 to n do read (a[i]);

22.

quicksort (1,n);

23.

for i:=1 to n-1 do begin

24.

t:=a[1]+a[2];

25.

s:=s+t;

26.

j:=3;

27.

while (t>a[j]) and (j<=n) do j:=j+1;

28.

j:=j-1; n:=n-1;

29.

for k:=1 to j-2 do a[k]:=a[k+2];

30.

a[j-1]:=t;

31.

for k:=j to n do a[k]:=a[k+1];

32.

end;

33.

writeln (s);

34.end.

Powered By RenQing | Developping By Wish Azuis 帮助 关于

鲁ICP备05014231号

Processed in 0.0625 second(s). Copyright (c) 2007-2009 Www.RQNOJ.Cn. All Rights R

查看更多回复
提交回复