编译都没过(
by YuZeAn @ 2023-01-09 19:02:57
@[YuZeAn](/user/736184) ...多打了一个"a"qaq
```cpp
#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;
for (int i = s; i <= n; i++) {
while (q.back() > sum[i - s] && !q.empty()) { //数组不空的情况下看队尾元素是否大于sum,是则出队
q.pop_back();
}
q.push_back(i - s);
while (!q.empty() && q.front() < i - t) {
q.pop_front();
}
if (sum[i] - q.front() >= 0 && !q.empty()) {
return true;
}
}
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;
}
```
by Stevehim @ 2023-01-09 19:13:53
if (sum[i] - q.front() >= 0 && !q.empty()) {
这里错了
@[Stevehim](/user/759274)
by shufentainanle @ 2023-06-11 15:17:32
@[shufentainanle](/user/934175) 前面也不对都应该是sum
by shufentainanle @ 2023-06-11 15:19:41