嚯呀嚯呀 @ 2017-06-04 20:09:36
我知道是多关键字排序,但为什么最后一个点过不去呢?
var
i,j,m,n,k,p:longint;
sum,chi,num:array[0..10000]of longint;
procedure qs(l,r:longint);
var
i,j,x,a1,a2,a3:longint;
begin
i:=l; j:=r;
x:=(l+r) div 2;
repeat
while (sum[i]>sum[x])or
((sum[i]=sum[x])and(chi[i]>chi[x]))or
((sum[i]=sum[x])and(chi[i]=chi[x])and(num[i]<num[x])) do inc(i);
while (sum[j]<sum[x])or
((sum[j]=sum[x])and(chi[j]<chi[x]))or
((sum[j]=sum[x])and(chi[j]=chi[x])and(num[j]>num[x])) do dec(j);
if not(i>j) then
begin
a1:=sum[i]; sum[i]:=sum[j]; sum[j]:=a1;
a2:=chi[i]; chi[i]:=chi[j]; chi[j]:=a2;
a3:=num[i]; num[i]:=num[j]; num[j]:=a3;
inc(i); dec(j);
end;
until i>j;
if i<r then
qs(i,r);
if l<j then
qs(l,j);
end;
begin
readln(n);
for i:=1 to n do
begin
readln(chi[i],k,p);
sum[i]:=chi[i]+k+p;
num[i]:=i;
end;
qs(1,n);
for i:=1 to 5 do
writeln(num[i],' ',sum[i]);
end.
by 周端阳 @ 2017-06-04 20:25:21
因为你太装逼了
by SSL_lzx @ 2017-06-04 20:35:19
好长啊~
by SSL_lzx @ 2017-06-04 20:36:27
明明选排就够的说
by Oceanyang @ 2017-07-21 17:11:36
@SSL_lzx 赞同
by 吴文涛 @ 2017-08-02 15:32:21
快排终究是有缺陷的,这里快排不太行啊
by 娄口肃行 @ 2017-08-06 09:55:50
n=300.............所以别用快排装B
by njsrxyr @ 2017-08-12 15:24:12
n=300 用什么快排。。。。。。
by lovelive__ @ 2017-08-14 15:07:54
明明不用用快排的说