Pagini recente » Cod sursa (job #1638550) | Cod sursa (job #1368916) | Cod sursa (job #691502) | Cod sursa (job #2806842) | Cod sursa (job #609730)
Cod sursa(job #609730)
Program orase;
type tip=record
x,y:longint;
end;
var a:array [1..50005] of tip;
b1:array [1..1 shl 10] of char;
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');
settextbuf(fi,b1);
reset(fi);
rewrite(fo);
readln(fi,n);
for i:=1 to n do readln(fi,a[i].x,a[i].y);
qsort(1,n);
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.