#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <cassert>
#include <vector>
#include <queue>
#include <set>
typedef long long llong;
const int MAXN = 200000 + 10;
const long double EPS = 1e-10;
const int INF = 2e9;
int n;
int a[MAXN];
llong prefix[MAXN];
long double calc(int l, int r)
{
return ((long double)(prefix[r] - prefix[l - 1])) / (r - l + 1);
}
long double check(long double from)
{
long double to = from;
int l = 1, r = n;
while (true)
{
to = std::max(to, calc(l, r));
if (l == r)
{
break;
}
if (calc(l, r - 1) > from)
{
r--;
} else
{
l++;
}
}
return to - from;
}
void solve()
{
for (int i = 1 ; i <= n ; ++i)
{
prefix[i] = prefix[i - 1] + a[i];
}
long double ans = 1e18;
for (int i = 1 ; i <= n ; ++i)
{
for (int j = i ; j <= std::min(n, i + 100) ; ++j)
{
if (calc(i, j) > calc(1, n)) break;
ans = std::min(ans, check(calc(i, j) - EPS));
}
}
std::cout << std::fixed << std::setprecision(10) << ans << '\n';
}
void input()
{
std::cin >> n;
for (int i = 1 ; i <= n ; ++i)
{
std::cin >> a[i];
}
}
void fastIOI()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main()
{
fastIOI();
input();
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
2 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2396 KB |
Output is correct |
7 |
Correct |
2 ms |
2504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
2 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2396 KB |
Output is correct |
7 |
Correct |
2 ms |
2504 KB |
Output is correct |
8 |
Correct |
809 ms |
2524 KB |
Output is correct |
9 |
Correct |
828 ms |
2508 KB |
Output is correct |
10 |
Correct |
809 ms |
2504 KB |
Output is correct |
11 |
Incorrect |
815 ms |
2640 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
2 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2396 KB |
Output is correct |
7 |
Correct |
2 ms |
2504 KB |
Output is correct |
8 |
Correct |
809 ms |
2524 KB |
Output is correct |
9 |
Correct |
828 ms |
2508 KB |
Output is correct |
10 |
Correct |
809 ms |
2504 KB |
Output is correct |
11 |
Incorrect |
815 ms |
2640 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |