Cod sursa(job #125742)

Utilizator ioalexno1Alexandru Bunget ioalexno1 Data 20 ianuarie 2008 17:17:02
Problema Stergeri Scor 30
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.46 kb
program alex;
var n,m,k,x,j,i,y:longint;
    a:array[1..10000000]of longint;
    f:text;
begin
assign(f,'stergeri.in');reset(f);
readln(f,n,m,k);
readln(f,x,y);
for j:=1 to x-1 do
    a[j]:=j;
for j:=y+1 to n do
    a[x+j-y-1]:=j;
n:=n-(y-x)-1;
for i:=2 to m do
    begin
    readln(f,x,y);
    for j:=y+1 to n do
        a[x+j-y-1]:=a[j];
    n:=n-(y-x)-1;
    end;
close(f);
assign(f,'stergeri.out');rewrite(f);
write(f,a[k]);
close(f);
end.