Pagini recente » Cod sursa (job #3038581) | Cod sursa (job #2192377) | Cod sursa (job #700604) | Cod sursa (job #3239424) | Cod sursa (job #3276298)
#ifdef LOCAL
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fantastice.in");
ofstream fout("fantastice.out");
#else
#include <bits/stdc++.h>
using namespace std;
ifstream fin("secv5.in");
ofstream fout("secv5.out");
#endif
int n, l, u;
int v[10500000];
long long twop(int mx){
unordered_map<long long, int> mp;
long long cnt=0, nr=0;
int s=1, d=1;
while(d<=n){
mp[v[d]]++;
if(mp[v[d]]==1) nr++;
d++;
while(nr>mx){
//cout<<s<<" "<<d<<'\n';
mp[v[s]]--;
if(mp[v[s]]==0){
nr--;
mp.erase(v[s]);
}
s++;
}
cnt+=d-s;
}
//cout<<cnt<<"\n";
return cnt;
}
int main()
{
fin>>n>>l>>u;
for(int i=1; i<=n; i++){
fin>>v[i];
}
if(l>=2)fout<<twop(u)-twop(l-1);
else fout<<twop(u);
return 0;
}