-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChef_and_Problems.c
More file actions
40 lines (39 loc) · 791 Bytes
/
Chef_and_Problems.c
File metadata and controls
40 lines (39 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<stdio.h>
int main()
{
long int n,m,k,i,j,l,r,pos1,pos2,count;
long int arr[100000];
scanf("%ld%ld%ld",&n,&m,&k);
for(i=0;i<n;i++)
{
if(arr[i]<=m)
scanf("%ld", &arr[i]);
}
while(k--)
{
l=r=pos1=pos2=0;
count=1;
scanf("%ld%ld",&l,&r);
for(i=l-1;i<r;i++)
{
pos1=i;
j=l;
while(j<r)
{
if(arr[i]==arr[j])
{
count++;
pos2=j;
j++;
}
else
j++;
}
}
if(count>1)
printf("%ld\n", pos2-pos1);
else
printf("0\n");
}
return 0;
}