# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199515 | SamAnd | Nivelle (COCI20_nivelle) | C++17 | 101 ms | 10744 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n;
char a[N];
int u[N][26];
int main()
{
scanf("%d", &n);
scanf(" %s", a);
for (int j = 0; j < 26; ++j)
u[n][j] = n;
for (int i = n - 1; i >= 0; --i)
{
for (int j = 0; j < 26; ++j)
u[i][j] = u[i + 1][j];
u[i][a[i] - 'a'] = i;
}
int x = N, y = 1;
int ansl = -1, ansr = -1;
for (int l = 0; l < n; ++l)
{
sort(u[l], u[l] + 26);
for (int j = 0; j < 26; ++j)
{
int r;
if (j < 25)
r = u[l][j + 1] - 1;
else
r = n - 1;
if ((j + 1) * y < x * (r - l + 1))
{
x = (j + 1);
y = (r - l + 1);
ansl = l;
ansr = r;
}
}
}
printf("%d %d\n", ansl + 1, ansr + 1);
return 0;
}
Compilation message (stderr)
# | 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... |