Pagini recente » Cod sursa (job #2094690) | Cod sursa (job #2728279) | Cod sursa (job #50018) | Cod sursa (job #1869128) | Cod sursa (job #2877994)
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
ifstream f("secv5.in");
ofstream g("secv5.out");
int n,l,u;
unsigned int a[1050000];
long long secventa(int x)
{
unordered_map<unsigned int,int> m;
int low=0,high=0;
long long nr=0,d=0;
while(high<n)
{
if(m[a[high]]==0) d++;
m[a[high]]++;
while(d>x)
{
m[a[low]]--;
if(m[a[low]]==0)
{
d--;
m.erase(a[low]);
}
low++;
}
if(d<=x)
nr+=high-low+1;
high++;
}
return nr;
}
int main()
{
f>>n>>l>>u;
for(int i=0; i<n; i++)
f >> a[i];
g<<secventa(u)-secventa(l-1);
return 0;
}