Cod sursa(job #2525215)
| Utilizator | Data | 16 ianuarie 2020 21:39:11 | |
|---|---|---|---|
| Problema | Secventa 5 | Scor | 80 |
| Compilator | cpp-32 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.68 kb |
#include <bits/stdc++.h>
#define DIM (1<<20)+3
using namespace std;
ifstream fin("secv5.in");
ofstream fout("secv5.out");
long long n,l,i,u,a=1,b=1,sol,v[DIM];
unordered_map<long long,int> st,dr;
int main() {
fin>>n>>l>>u;
for (i=1;i<=n;i++)
fin>>v[i];
for (i=1;i<=n;i++) {
st[v[i]]++, dr[v[i]]++;
while (st.size()>=l) {
st[v[a]]--;
if (st[v[a]]==0)
st.erase(v[a]);
a++;
}
while (dr.size()>u) {
dr[v[b]]--;
if (dr[v[b]]==0)
dr.erase(v[b]);
b++;
}
sol+=a-b;
}
fout<<sol;
return 0;
}
