#include <bits/stdc++.h>
#define SPED \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define endl "\n"
#define fi first
#define se second
#define lint long long
#define fami signed
#define lore main
#define freefire freopen
const lint INF = 0x1f1f1f1f1f1f1f1f;
const lint NEG = 0xE1E1E1E1E1E1E1E1;
using namespace std;
int n;
int a[100005];
fami lore()
{
SPED;
cin >> n;
for (int i = 1; i <= n; i++)
{
char c;
cin >> c;
a[i] = c - 'a';
}
double mini = 100000;
int L = 0, R = 0;
for (double diff = 1; diff <= 26; diff++)
{
int l = 1;
double now = 0;
static int x[30];
memset(x, 0, sizeof x);
for (int r = 1; r <= n; r++)
{
++x[a[r]];
if (x[a[r]] == 1)
++now;
while (now > diff)
{
--x[a[l]];
if (x[a[l]] == 0)
--now;
++l;
}
double sech = (r - l + 1);
if (mini > now / sech)
{
mini = now / sech;
L = l;
R = r;
}
}
}
cout << L << " " << R;
}
// Let your soul wander where dreams are born.
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |