Cod sursa(job #9598)

Utilizator icecoldGosu Valentin icecold Data 27 ianuarie 2007 16:22:12
Problema Secventa 5 Scor 0
Compilator fpc Status done
Runda Unirea 2007, clasele 11-12 Marime 0.84 kb
var f,g:text;
    v:array[1..500000000] of longint;
    p:array[1..500000000] of 0..1;
    n,l,u,i,j,suma,nrel:longint;

function elem(a,b:longint):longint;
var i,j,q:longint;
begin
q:=0;
for i:=a to a+b-1 do
         if p[i]=0 then begin
            q:=q+1;
            for j:=i+1 to b do
                if v[i]=v[j] then p[j]:=1;
            end;
for i:=a to b do p[i]:=0;
elem:=q;
end;


begin
assign(f,'secv5.in');
assign(g,'secv5.out');
reset(f);
rewrite(g);
read(f,n,l,u);
readln(f);
for i:=1 to n do readln(f,v[i]);
for i:=1 to n do begin
                 for j:=1 to n-i+1 do begin
                                      nrel:=elem(i,j);
                                      if (nrel<=u) and (nrel>=l) then suma:=suma+1;
                                      end;
                 end;
writeln(g,suma);
close(g);
end.