Pagini recente » Cod sursa (job #1598379) | Cod sursa (job #744978) | Cod sursa (job #49857) | Cod sursa (job #2299341) | Cod sursa (job #9829)
Cod sursa(job #9829)
program alt;
type vec=array[1..maxint]of integer;
var v:array[1..maxint]of longint;
n,l,u,i,j,k:longint;
g:text;
ap:vec;
procedure citire;
var f:text;
begin
assign(f,'secv5.in');reset(f);
read(f,n,l,u);
for i:=1 to n do read(f,v[i]);
close(f);
end;
function ver(i,j:integer;ap:vec):boolean;
var x:boolean;
h,el,n:longint;
begin
el:=0;
n:=i;
while (n<=j)and(el<=u) do
begin
if ap[v[n]]=0 then inc(el);
inc(ap[v[n]] );
inc(n);
end;
if (el<l)or(el>u) then ver:=false
else ver:=true;
end;
begin {pp};
citire;
for i:=1 to n-l+1 do
begin
j:=i+1;
while (j<=n) do
begin
if ver(i,j,ap) then inc(k);
inc(j);
end;
end;
assign(g,'secv5.out');rewrite(g);
write(g,k);
close(g);
end.