Pagini recente » Cod sursa (job #3128259) | Cod sursa (job #252549) | Cod sursa (job #2285403) | Cod sursa (job #2794044) | Cod sursa (job #609726)
Cod sursa(job #609726)
Program orase;
type tip=record
x,y:longint;
end;
var a:array [1..100000] of tip;
i,j,max,sol,n,d:longint;
fi,fo:text;
procedure qsort(l,r:longint);
var k,i,j:longint;
y:tip;
begin
i:=l; j:=r;
k:=a[(l+r) div 2].x;
repeat
while a[i].x<k do inc(i);
while a[j].x>k do dec(j);
if i<=j then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i); dec(j);
end;
until i>=j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
assign(fi,'orase.in');
assign(fo,'orase.out');
reset(fi);
rewrite(fo);
readln(fi,n);
for i:=1 to n do readln(fi,a[i].x,a[i].y);
qsort(1,n);
max:=-1000000;
for i:=2 to n do begin
if a[i-1].y-a[i-1].x>max then max:=a[i-1].y-a[i-1].x;
d:=a[i].y+a[i].x+max;
if d>sol then sol:=d;
end;
write(fo,sol);
close(fo);
end.