Pagini recente » Cod sursa (job #2528624) | Cod sursa (job #687754) | Cod sursa (job #437715) | Cod sursa (job #2754607) | Cod sursa (job #3276295)
#ifdef LOCAL
#include <bits/stdc++.h>
using namespace std;
ifstream fin("file.in");
ofstream fout("file.out");
#else
#include <bits/stdc++.h>
using namespace std;
ifstream fin("secv5.in");
ofstream fout("secv5.out");
#endif
unsigned int n;
unsigned int v[2000005],l,u;
int panetone(int x)
{
unordered_map<int,int>m;
unsigned int st=0,elem=0,ans=0;
for(int dr=1;dr<=n;++dr)
{
m[v[dr]]++;
if(m[v[dr]]==1)
{
elem++;
while(x<elem)
{
st++;
m[v[st]]--;
if(m[v[st]]==0)elem--;
}
}
ans+=dr-st;
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
fin>>n>>l>>u;
for(int i=1;i<=n;++i)
{
fin>>v[i];
}
cout<<panetone(u)<<" "<<panetone(l-1);
fout<<panetone(u)-panetone(l-1);
return 0;
}