Pagini recente » Cod sursa (job #2295527) | Cod sursa (job #2510515) | Cod sursa (job #711609) | Cod sursa (job #2479250) | Cod sursa (job #2524703)
#include <cstdio>
#include <unordered_map>
using namespace std;
const int DIM = (1 << 17);
unsigned n, l, u;
long long ans;
unsigned v[1048580];
unordered_map <unsigned, unsigned> st, dr;
char nxt() {
static char buff[DIM];
static int bp = DIM;
if(bp == DIM) {
fread(buff, 1, DIM, stdin);
bp = 0;
}
return buff[bp++];
}
void read(unsigned &x) {
x = 0;
static char ch;
do {
ch = nxt();
} while(ch < '0' || '9' < ch);
do {
x = x * 10 + ch - '0';
ch = nxt();
} while('0' <= ch && ch <= '9');
}
int main() {
freopen("secv5.in", "r", stdin);
freopen("secv5.out", "w", stdout);
read(n), read(l), read(u);
for(unsigned i = 1; i <= n; i++)
read(v[i]);
unsigned j1 = 1, j2 = 1;
for(unsigned i = 1; i <= n; i++) {
st[v[i]]++; dr[v[i]]++;
while(st.size() >= l) {
st[v[j1]]--;
if(st[v[j1]] == 0 )
st.erase(v[j1]);
j1++;
}
while(dr.size() > u) {
dr[v[j2]]--;
if(dr[v[j2]] == 0)
dr.erase(v[j2]);
j2++;
}
ans += j1 - j2;
}
printf("%lld", ans);
return 0;
}