Pagini recente » Borderou de evaluare (job #1765362) | Cod sursa (job #786555) | Cod sursa (job #3144392) | Cod sursa (job #2206187) | Cod sursa (job #3182141)
/**
* Author: Andu Scheusan (not_andu)
* Created: 08.12.2023 17:12:23
*/
#include <bits/stdc++.h>
#include <unordered_map>
#pragma GCC optimize("O3")
using namespace std;
#define INFILE "secv5.in"
#define OUTFILE "secv5.out"
typedef long long ll;
const int VMAX = 1e7;
int n, lowLimit, upLimit;
ll v[VMAX];
ll getMaxDistinct(int k){
unordered_map<int, int> fr;
int left = 1, right = 1;
ll aux = 0;
ll ans = 0;
while(right <= n){
++fr[v[right]];
if(fr[v[right]] == 1){
++aux;
}
++right;
while(aux > k){
--fr[v[left]];
if(fr[v[left]] == 0){
--aux;
}
++left;
}
ans += (right - left);
}
return ans;
}
void solve(){
cin >> n >> lowLimit >> upLimit;
for(int i = 1; i <= n; ++i) cin >> v[i];
cout << getMaxDistinct(upLimit) - getMaxDistinct(lowLimit - 1) << '\n';
}
int main(){
ios_base::sync_with_stdio(false);
freopen(INFILE, "r", stdin);
freopen(OUTFILE, "w", stdout);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}