Pagini recente » Cod sursa (job #1707158) | Cod sursa (job #885702) | Cod sursa (job #126800) | Cod sursa (job #1589202) | Cod sursa (job #3185784)
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream cin("secv5.in");
ofstream cout("secv5.out");
int v[2000005];
int l,a,b,n;
long long cnt(int x){
long long i=0,j=0,ans=0,nr=0;
unordered_map <long long,int> frecv;
while(j<n){
frecv[v[j]]++;
if(frecv[v[j]]==1)nr++;
while(nr>x){
frecv[v[i]]--;
if(frecv[v[i]]==0)nr--;
i++;
}
ans+=j-i;
j++;
}
return ans;
}
int main()
{
cin>>n>>a>>b;
for (int i = 0; i < n; i++) {
cin>>v[i];
}
cout<<cnt(b)-cnt(a-1);
return 0;
}