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>
#define int int64_t
using namespace std;
constexpr static int INF = 3e14;
constexpr static double EPSILON = 0.000000000001;
constexpr static int MXSIZE = 200000;
int a[MXSIZE];
int32_t main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
int sum = 0;
for (int i = 0; i < n; i++)
sum += a[i];
int la = sum, lb = n, ra = sum, rb = n;
int step = 0;
for (int l=0,r=n;r>l;step^=1)
{
if (step&1)
{
sum -= a[l++];
if (ra * (r-l) < sum * rb)
{
ra = sum;
rb = r-l;
}
}
else
{
sum -= a[--r];
if (la * (r-l) > sum * lb)
{
la = sum;
lb = r-l;
}
}
}
double right = static_cast<double>(ra) / rb;
double left = static_cast<double>(la) / lb;
cout << fixed;
cout << setprecision(15);
cout << (right - left + EPSILON) <<"\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... |