- 奖学金
- 2013-07-16 17:21:03 @
var
n,i:longint;
num,sum,yu,shu,ying:array[1..300]of longint;
procedure qsort(l,r:longint);
var i,j,p,mid:longint;
begin
i:=l;j:=r;mid:=sum[num[(l+r)div 2]];
repeat
while sum[num[i]]>mid do inc(i);
while sum[num[j]]<mid do dec(j);
if i<=j then
begin
p:=num[i];num[i]:=num[j];num[j]:=p;
if sum[num[i]]=sum[num[j]]then
begin
if yu[num[i]]<yu[num[j]] then
begin
p:=num[i];num[i]:=num[j];num[j]:=p;
end;
if yu[num[i]]=yu[num[j]] then
if num[i]>num[j] then
begin
p:=num[i];num[i]:=num[j];num[j]:=p;
end;
end;
inc(i);dec(j);
end;
until i>j;
if i<r then qsort(i,r);
if l<j then qsort(l,j);
end;
begin
readln(n);
for i:=1 to n do
begin
readln(yu[i],shu[i],ying[i]);
num[i]:=i;
sum[i]:=yu[i]+shu[i]+ying[i];
end;
qsort(1,n);
for i:=1 to 5 do writeln(num[i],' ',sum[num[i]]);
end.