rt
#include <bits/stdc++.h>
#define maxn 1000010
using namespace std;
double sum[maxn];
double a[maxn];
deque<double> q;
int n;
int s, t;
double all;
//参考题解
bool can(double mid) {
for (int i = 1; i <= n; i++) {
sum[i] = sum[i - 1] + a[i] - mid;
}
int t1 = 0;
cout << "ok1" << endl;
for (int i = s; i <= n; i++) {
while (q.back() > sum[i - s] && !q.empty()) { //数组不空的情况下看队尾元素是否大于sum,是则出队
q.pop_back();
}
q.push_back(i - s);a
while (!q.empty() && q.front() < i - t) {
q.pop_front();
}
if (sum[i] - q.front() >= 0 && !q.empty()) {
cout << "ok2" << endl;
return true;
}
}
cout << "ok2" << endl;
return false;
}
int main() {
cin >> n;
cin >> s >> t;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum[i] = sum[i - 1] + a[i];
all += a[i];
}
all /= n; //把平均值求出来
double l = 0, r = all;
while (r - l >= 0.001) {
double mid = (l + r) / 2;
if (can(mid)) {
l = mid;
all = mid;
} else {
r = mid + 1;
}
}
cout << all;
return 0;
}
属于连题解都看不懂的fw了