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 <iostream>
#define endl "\n"
#define fi first
#define se second
using namespace std;
int main() {
cout.tie(0);
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
int n, cont;
pair<int, int> ans[27]{};
string s;
cin>>n>>s;
for(int k=1; k<=26; k++){
int l[26]{};
cont=0;
for(int i=0, j=0; i<n; i++){
if(!l[s[i]-'a']) cont++;
l[s[i]-'a']++;
while(cont>k){
l[s[j]-'a']--;
if(l[s[j]-'a']==0) cont--;
j++;
}
if(i-j>=ans[k].se-ans[k].fi){
ans[k].se=i+1;
ans[k].fi=j+1;
}
}
}
float acidez=n+1, X, L=0, R=0;
for(int i=1; i<=26; i++){
X=i;
X/=(ans[i].se-ans[i].fi+1);
if(X<acidez){
acidez=X;
L=ans[i].fi;
R=ans[i].se;
}
}
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... |