Pagini recente » Cod sursa (job #1027290) | Cod sursa (job #2465304) | Cod sursa (job #3194991) | Cod sursa (job #3153873) | Cod sursa (job #1459354)
#include<cstdio>
#include<unordered_map>
#define dim (1<<20) + 2
using namespace std;
long long int n,L,U;
unsigned int v[dim];
unordered_map<unsigned int, unsigned int> H;
inline long long int Secv(int nr)
{
long long int rez = 0;
int i, j;
for(i = 0, j = 0; i < n; ++i)
{
++H[v[i]];
while( H.size() > nr )
{
--H[v[j]];
if( !H[v[j]] )
H.erase(v[j]);
++j;
}
rez += 1LL * ( i - j + 1 );
}
return rez;
}
int main()
{
freopen("secv5.in","r",stdin);
freopen("secv5.out","w",stdout);
scanf("%lld%lld%lld", &n, &L, &U);
unsigned long long a, b;
for ( int k = 0; k < n; k++)
scanf("%ud", &v[k]);
a= Secv(U);
H.clear();
b= Secv(L - 1);
printf("%lld", a - b);
}