64分 3、4、5号点TLE
前缀和用了,单调队列也用了,我真不知道怎么优化了。。。
#include <iostream>
#include <queue>
using namespace std;
int n, m, ans;
int a[500001];
deque<int> q;
void push(int x) {
while(!q.empty() && x >= q.back()) q.pop_back();
q.push_back(x);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i++) {
cin >> a[i];
a[i] += a[i - 1];
}
for(int i = 1; i <= m; i++) {
for(int j = i; j <= n; j++) {
push(a[j] - a[j - i]);
}
}
cout << q.front();
return 0;
}