Mai intai trebuie sa te autentifici.
Cod sursa(job #3325605)
| Utilizator | Data | 25 noiembrie 2025 20:07:05 | |
|---|---|---|---|
| Problema | Secventa 5 | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.8 kb |
#include <fstream>
using namespace std;
ifstream cin("secv5.in");
ofstream cout("secv5.out");
int arr[1048577], cnt[1048577];
bool aparut[4294967297];
int main()
{
int n, l, u, max = 0, cntSecv = 0;
cin >> n >> l >> u;
cnt[0] = 0;
for (int i = 1; i <= n; i++)
{
cnt[i] = cnt[i - 1];
cin >> arr[i];
if (aparut[arr[i]] == false)
{
cnt[i]++;
aparut[arr[i]] = true;
}
//cout << cnt[i] << "\n";
}
for (int i = 1; i <= n; i++)
{
int ci = i + 1;
if (l <= cnt[i] && cnt[i] <= u)
{
while (ci <= n && cnt[ci] == cnt[i])
{
ci++;
}
cntSecv += ci - i + 1;
}
}
cout << cntSecv + 1;
}
