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;
#define int long long
void solve(){
string str = "abcde";
int k = 5;
int n;cin >> n;
int arr[n],cur[n];
for(int i = 0;i<n;i++){
char ch;cin >> ch;
arr[i] = ch - 'a';
}
memset(cur , 0 , sizeof(cur));
int pay = 1 , payda = 0 , l = 1 , r = 1;
for(int bit = 0;bit < (1 << k);bit++){
for(int j = 0;j<n;j++){
cur[j] = (bit >> arr[j]) & 1;
}
int mx = 0 , sayac = 0 , templ = 1 , tempr = 1;
for(int i = 0;i<=n;i++){
if(i != n and cur[i] == 1){
sayac++;
}
else{
if(mx < sayac){
mx = sayac;
templ = i - sayac + 1;
tempr = i;
}
sayac = 0;
}
}
if(pay * mx > ((int)__builtin_popcount(bit)) * payda){
pay = ((int)__builtin_popcount(bit));
payda = mx;
l = templ;
r = tempr;
}
}
cout << l << " " << r << endl;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;//cin >> testcase;
while(testcase--)solve();
}
# | 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... |