#include "bits/stdc++.h"
using namespace std;
#define ar array
typedef int64_t ll;
#define int ll
const int N = 1e5 + 5;
int pref[N], suff[N];
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
string s; cin>>s;
int n = s.size();
for(int i=0;i<n;i++){
if(i) pref[i] += pref[i-1];
pref[i] += i;
}
for(int i=n-1;~i;i--){
suff[i] += suff[i+1];
suff[i] += (n - i - 1);
}
int res = pref[n-1];
for(int i=1;i<n;i++){
res = min(res, pref[i-1] + suff[i]);
}
cout<<res / 2.<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |