Pagini recente » Cod sursa (job #1965689) | Cod sursa (job #680059) | Cod sursa (job #1043815) | Cod sursa (job #1527922) | Cod sursa (job #3274462)
#include<bits/stdc++.h>
using namespace std;
ifstream fin("secv5.in");
ofstream fout("secv5.out");
int n, L, U;
long long a[1000005];
unordered_map<long long, int> M;
/**
i
13 13 7 9 9
*/
long long salamakeum(int x)
{
int i = 1, j = 1, bruh = 0;
long long cnt = 0;
M.clear();
while(i <= n)
{
if(M[a[i]] == 0)
bruh++;
M[a[i]]++;
while(bruh > x)
{
M[a[j]]--;
if(M[a[j]] == 0)
bruh--;
j++;
}
cnt += (i - j + 1);
i++;
}
return cnt;
}
int main()
{
ios::sync_with_stdio(0);
fin.tie(0);
fout.tie(0);
int i;
fin >> n >> L >> U;
for(i = 1; i <= n; i++)
fin >> a[i];
fout << salamakeum(U) - salamakeum(L - 1);
return 0;
}