Cod sursa(job #9679)

Utilizator DorinOltean Dorin Dorin Data 27 ianuarie 2007 16:39:03
Problema Secventa 5 Scor 0
Compilator cpp Status done
Runda Unirea 2007, clasele 11-12 Marime 0.67 kb
# include <stdio.h>

# define input "secv5.in"
# define output "secv5.out"

# define max 4001001

long a,b,n,i,j,st,dist,rez,gasit,val;
long long unsigned x[max];

int main()
{
	freopen(input,"r",stdin);
	freopen(output,"w",stdout);

	scanf("%ld%ld%ld",&n,&a,&b);

	st = 1;

	for(i = 1;i<=n;i++)
	{
		scanf("%ld",&x[i]);
		
		j=i-1;
		dist=1;
		while(j>=st && dist<=b)
		{
			gasit = 0;
			for(val=j+1;val<=i;val++)
			{
				if(x[j] == x[val])
				{
				   gasit =1;
				   break;
				}
			}
			if(!gasit)
				dist++;
			j--;
			if(dist >= a && dist <= b)
				rez++;
        }
        st = j+1;
	}

    printf("%ld",rez);

	return 0;
}