# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
888100 | votranngocvy | Nivelle (COCI20_nivelle) | C++14 | 24 ms | 952 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 = 1e5 + 5;
const int inf = 0x3f3f3f3f;
int a[N];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
char x;
cin >> x;
a[i] = x - 'a';
}
double ans = inf;
int L,R;
for (int i = 1; i <= 26; i++) {
vector<int>cnt(30,0);
int l = 1,tmp = 0;
for (int r = 1; r <= n; r++) {
cnt[a[r]]++;
if (cnt[a[r]] == 1) tmp++;
while (tmp > i) {
cnt[a[l]]--;
if (cnt[a[l]] == 0) tmp--;
l++;
}
if (tmp == i && (double)i / (double)(r - l + 1) < ans) {
ans = (double)i / (double)(r - l + 1);
L = l,R = r;
}
}
}
cout << L << " " << R << "\n";
}
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... |