제출 #791347

#제출 시각아이디문제언어결과실행 시간메모리
791347Saul0906Nivelle (COCI20_nivelle)C++14
0 / 110
18 ms628 KiB
#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=1e9, X, L=0, R=0; for(int i=1; i<=26; i++){ X=i+1; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...