这个代码为什么编译错误?
查看原帖
这个代码为什么编译错误?
231591
FishingStar楼主2020/11/20 22:47
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;
struct qwq{
    long long time, t;
};
qwq a[300005];
long long s[300005];
int main(){
    register int n, l, r;
    cin >> n >> l >> r;
    for(int i = 0; i <= n; i++){
    	cin >> a[i].t;
    	a[i].time = i;
	}
	deque<qwq> q;
	for(int i = 1; i <= n + r; i++){
		while(!q.empty() && q.front().time < i - r){
		    q.pop_front();
		}
		while(!q.empty() && q.end().t < a[i].t){
		    q.pop_back();
		}
		q.push_back(a[i]);
		s[i] = q.front() + a[i].t;
	}
	long long ans  = -1e18;
	for(int i = n + 1; i <= n + r; i++){
	    ans = max(ans, s[i]);
	}
	cout << ans;
    return 0;
}
2020/11/20 22:47
加载中...