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>
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a << " = " << fixed << setprecision(1) << a << endl
#define debugsl(a) cout << #a << " = " << fixed << setprecision(1) << a << ", "
#define rep(i,a,b) for(int i = (a); i<=(b); i++)
#define repa(i,a,b) for(int i = (a); i>=(b); i--)
#define pll pair<lli,lli>
#define MAX 100000
lli n,k;
long double dp[MAX+2],res,a;
string st;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> st;
n = st.size();
if (n == 1 || n == 2) {
cout << "0.000";
return 0;
}
res = -1;
rep(i,2,n) {
a = (i-1);
a /= 2;
dp[i] = dp[i-1] + a;
k = n-i;
if (k <= i) {
a = dp[k] + dp[i];
if (res < 0 || a < res) res = a;
}
}
//rep(i,1,n) debug(dp[i]);
cout << fixed << setprecision(3) << res;
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... |