Pagini recente » Cod sursa (job #3150687) | Cod sursa (job #577593) | Cod sursa (job #2881175) | Cod sursa (job #2800494) | Cod sursa (job #2868648)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("secv5.in");
ofstream fout("secv5.out");
int n, l, u, a[1100000];
unordered_map <int, int> M;
long long Nr(int x)
{
int i, p = 1, cnt = 0;
long long sol = 0;
for (i = 1; i <= n; i++)
{
M[a[i]]++;
if (M[a[i]] == 1)
cnt++;
while (cnt > x)
{
M[a[p]]--;
if (M[a[p]] == 0)
cnt--;
p++;
}
sol += (i - p + 1);
}
return sol;
}
int main()
{
long long i, x, y;
fin >> n >> l >> u;
for (i = 1; i <= n; i++)
fin >> a[i];
x = Nr(u);
M.clear();
y = Nr(l - 1);
fout << x - y << "\n";
return 0;
}