Skip to content

Instantly share code, notes, and snippets.

@ernado
Created March 16, 2012 08:42
Show Gist options
  • Save ernado/2049183 to your computer and use it in GitHub Desktop.
Save ernado/2049183 to your computer and use it in GitHub Desktop.
C42.pas
uses crt;
type
r = record
f : string[35];
b : word;
end;
const
Nm = 100;
Sm = 401;
var
c:char;
b1,b2,b3,n,i : byte;
min1,min2,min3,k : word;
a : array[1..Nm] of r;
begin
ClrScr;
readln(n);
for i:=1 to n do
begin
a[i].f := '';
repeat
read(c); a[i].f := a[i].f + c;
until (c = ' ');
repeat
read(c); a[i].f := a[i].f + c;
until (c = ' ');
ReadLn(b1,b2,b3);
a[i].b := b1+b2+b3;
end;
min1:=Sm; min2:=Sm; min3:=Sm;
for i:=1 to n do
begin
k:=a[i].b;
if (k <= min1) then
begin
min3:=min2;
min2:=min1;
min1:=k;
end else
if (k <= min2) then
begin
min3:=min2;
min2:=k;
end else
if (k <= min3) then min3:=k;
end;
for i:=1 to n do
begin
k:=a[i].b;
if (k = min1) or (k = min2) or (k = min3) then
WriteLn(a[i].f);
end;
ReadKey;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment