Pagini recente » Cod sursa (job #828922) | Istoria paginii runda/rar96/clasament | Cod sursa (job #199236) | Cod sursa (job #317738) | Cod sursa (job #1766273)
#include <iostream>
#include<fstream>
#include<vector>
using namespace std;
typedef unsigned int uint;
const uint mod=99017;
vector< pair<uint,int> > h[mod+5];
uint x,key;
int v[(1<<20)+5],n,p,u,i,i1,i2,j,neww,ap[(1<<20)+5],dist1,dist2;
long long tot;
bool moved;
void ins()
{
key=x%mod;
for(j=0;j<h[key].size();j++)
if(h[key][j].first==x)
{
v[i]=h[key][j].second;
return;
}
neww++;
v[i]=neww;
h[key].push_back(make_pair(x,neww));
}
int main()
{
ifstream f("secv5.in");
ofstream g("secv5.out");
f>>n>>p>>u;
for(i=1;i<=n;i++)
{
f>>x;
ins();
}
i1=0;i2=0;
for(i=1;i<=n;i++)
{
if(ap[v[i]]==0)
dist1++,dist2++;
ap[v[i]]++;
while(dist1>=p)
{
if(ap[v[i1]]==1) dist1--;
ap[v[i1]]--;
i1++;
}
while(dist2>u)
{
if(ap[v[i2]]==1) dist2--;
ap[v[i2]]--;
i2++;
}
if(i1!=0)tot+=i1-i2-1;
}
g<<tot;
return 0;
}