이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN=200001;
const ll MAXK=1000001;
const ll INF = 1e9;
const ll MOD = 1e9+7;
string S;
int A[MAXN];
int p[MAXN];
int N;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>N>>S;
for(int i=0;i<26;++i){
int x=-1;
for(int t=0;t<N;++t)if(S[t]-'a'==i){
p[t]=x;
x=t;
}
}
ld optcst=-1;
pi ans=mp(-1,-1);
for(int st=0;st<N;++st){
int l=0;
int u=0;
for(int en=st;en<N;++en){
++l;
if(p[en]<st)++u;
ld c=(ld)l/(ld)u;
if(c>optcst){
ans=mp(st,en);
optcst=c;
}
}
}
cout<<ans.f+1<<' '<<ans.s+1<<'\n';
}
# | 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... |