Cod sursa(job #11312)

Utilizator monica88Golumbeanu Monica monica88 Data 31 ianuarie 2007 10:57:42
Problema Secventa 5 Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1 kb
program secv5;
var a:array[1..100] of 0..100;
    {r:array[1..100] of 0..1000000000;}
    i,j,u,n,l,c,ret:0..100;
    f:text;

function lung(p,q:integer):integer;
var i,j,l:integer;
ok:boolean;
begin
     l:=0;
     for i:=p to q do
         begin
              ok:=true;
              for j:=i+1 to q do
                 if (a[i]=a[j]) and (i<>j) then
                    begin
                         ok:=false;
                         break;
                    end;
              if ok then l:=l+1;
              if l>u then break;
         end;
     lung:=l;
end;

begin
     assign(f,'secv5.in'); reset(f); readln(f,n,l,u);
     for i:=1 to n do
         readln(f,a[i]);
     close(f);
     ret:=0;
     for i:=1 to n do
         for j:=i+l-1 to n do
             begin
                  c:=lung(i,j);
                  if (l<=c) and (c<=u) then
                     ret:=ret+1;
             end;
     assign(f,'secv5.out'); rewrite(f); writeln(f,ret);
     close(f);
end.