Pagini recente » Cod sursa (job #1207714) | Cod sursa (job #782132) | Cod sursa (job #1094796) | Cod sursa (job #1188457) | Cod sursa (job #1280405)
#include<cstdio>
#include<algorithm>
#include<unordered_map>
using namespace std;
unordered_map<int,int>s;
int n,i,j,k,lg,x,y,v[110000];
long long solve(int x)
{
s.clear();
long long rez=0;
int j=1;
for(int i=1;i<=n;i++)
{
s[v[i]]++;
while(s.size()>x)
{
if (s[v[j]]==1) s.erase(v[j]);else
s[v[j]]--;
j++;
}
rez=rez+i-j+1;
}
return rez;
}
int main()
{
freopen("secv5.in","r",stdin);
freopen("secv5.out","w",stdout);
scanf("%d %d %d",&n,&x,&y);
for(i=1;i<=n;i++)
scanf("%d",&v[i]);
printf("%d\n",solve(y)-solve(x-1));
return 0;
}