- 奖学金
- 2016-05-20 17:48:01 @
program p1_1(input,output);
var
n,i1,i2,o,q:longint;
a:array [1..5000,1..5000] of longint;
sum,b:array [1..5000] of longint;
procedure f;
begin
o:=sum[i1];
sum[i1]:=sum[i2];
sum[i2]:=o;
q:=b[i1];
b[i1]:=b[i2];
b[i2]:=q;
end;
begin
readln(n);
q:=1;
for i1:=1 to n do begin
for i2:=1 to 3 do begin
read(a[i1,i2]);
if a[i1,i2]<=100 then begin
sum[i1]:=sum[i1]+a[i1,i2];
b[i1]:=q;
end;
end;
inc(q);
end;
for i1:=1 to n-1 do
for i2:=i1+1 to n do begin
if sum[i2]>sum[i1] then f
else if (sum[i1]=sum[i2]) and (a[i1,1]<a[i2,1]) then f
else if (sum[i1]=sum[i2]) and (a[i1,1]<a[i2,1]) and (b[i1]>b[i2]) then f;
end;
for i1:=1 to 5 do if sum[i1]<>0 then writeln(b[i1],' ',sum[i1]);
end.