什么鬼???

P1093 [NOIP2007 普及组] 奖学金

蛟川洋 @ 2017-08-17 16:00:51

为什么我样例2都过不了,BUT,居然AC了!

代码附上:

program P1093;
var
        sc,s,num:array[1..300] of longint;
        n,sm,se,i:longint;
procedure change(var a,b:longint);
var c:longint;
begin
c:=a;
a:=b;
b:=c;
end;
procedure qs(l,r:longint);
var x,m,i,i1:longint;
begin
m:=(l+r) div 2;
x:=s[m];
i:=l;
i1:=r;
repeat
 while (x<s[i]) or ((x=s[i]) and (sc[m]<sc[i])) or ((x=s[i]) and (sc[m]=sc[i]) and (num[m]>num[i])) do
  begin
  inc(i);
  end;
 while (x>s[i1]) or ((x=s[i1]) and (sc[m]>sc[i1])) or ((x=s[i1]) and (sc[m]=sc[i1]) and (num[m]<num[i1])) do
  begin
  dec(i1);
  end;
 if i<=i1
    then
    begin
    change(sc[i],sc[i1]);
    change(s[i],s[i1]);
    change(num[i],num[i1]);
    inc(i);
    dec(i1);
    end;
until i>i1;
if l<i1 then qs(l,i1);
if r>i then qs(i,r);
end;
begin
        readln(n);
        for i:=1 to n do
         begin
         readln(sc[i],sm,se);
         s[i]:=sc[i]+sm+se;
         num[i]:=i;
         end;
        qs(1,n);
        for i:=1 to 5 do
         begin
         writeln(num[i],' ',s[i]);
         end;
end.

|