Cod sursa(job #2039002)
| Utilizator | Data | 14 octombrie 2017 10:32:59 | |
|---|---|---|---|
| Problema | Secventa 5 | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.63 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("secv5.in");
ofstream fout("secv5.out");
unsigned int a[1024*1025+50],n,L,U;
int NrSecv(int k)
{
map<unsigned int,int>M;
int i,j;
long long cnt=0;
i=1;
for(j=1;j<=n;j++)
{
M[a[j]]++;
while(M.size()>k)
{
M[a[i]]--;
if(M[a[i]]==0)
M.erase(a[i]);
i++;
}
cnt += (j-i+1);
}
return cnt;
}
int main()
{
fin>>n>>L>>U;
for(int i=1;i<=n;i++)
fin>>a[i];
cout<<NrSecv(U)-NrSecv(L-1)<<"\n";
return 0;
}
