#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 |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |