Pagini recente » Cod sursa (job #1651921) | Diferente pentru runda/vot/voteaza_zaharel intre reviziile 2 si 6 | Cod sursa (job #834150) | Cod sursa (job #2330786) | Cod sursa (job #1561719)
#include <bits/stdc++.h>
#define int64 long long
using namespace std;
ifstream in("secv5.in");
ofstream out("secv5.out");
unsigned a[1111111];
int n,x,y,k;
int64 solve(unsigned t)
{
unordered_map<unsigned,int> h;
int64 sol=0,last=1;
for(int i=1;i<=n;i++)
{
h[a[i]]++;
while(h.size()>t)
{
h[a[last]]--;
if(h[a[last]]==0)
h.erase(a[last]);
last++;
}
sol+=(i-last+1);
}
return sol;
}
int main()
{
in>>n>>x>>y;
for(int i=1;i<=n;i++)
in>>a[i];
out<<solve(y)-solve(x-1)<<'\n';
return 0;
}