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;
int n;
string s;
double res = 1e9;
int l = 0, r = 0;
int last[26];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> s;
s = " " + s;
for (int i = n; i >= 1; -- i) {
last[s[i]-'a'] = i;
vector<int> min_pos = {n+1};
for (int j = 0; j < 26; ++ j)
if (last[j])
min_pos.push_back(last[j]);
sort(min_pos.begin(), min_pos.end());
for (int j = 0; j + 1 < (int)min_pos.size(); ++ j) {
double cur = (double)(j + 1) / (min_pos[j+1] - i);
if (res > cur) {
res = cur;
l = i;
r = min_pos[j+1] - 1;
}
}
}
cout << l << " " << r;
return 0;
}
# | 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... |