MnZn求助玄关

P1725 琪露诺

Fu_Tao @ 2024-07-25 19:08:34

WA Hack#1

#define it <> ::iterator
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <bitset>
#include <cstdio>
#include <vector>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;
typedef long long ll;//unsigned
const ll nex[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
const ll inf=2147483648;
const ll mod=1e9+7;
ll n,l,r,a[1000001],ans,dp[1000001];
deque<ll> q;
int main(){
    cin>>n>>l>>r;
    for(int i=0;i<=n;i++){
        cin>>a[i];
        dp[i]=-inf;
    }dp[0]=0;
    for(int i=l;i<=n;i++){
        while(!q.empty()&&q.front()<i-r)q.pop_front();
        while(!q.empty()&&dp[q.back()]<=dp[i-l])q.pop_back();
        q.push_back(i-l);
        dp[i]=dp[q.front()]+a[i];
        if(i+r>n)ans=max(dp[i],ans);
    }
    cout<<ans;
    return 0;
} 

玄关


by _Paradox_ @ 2024-07-26 13:40:35

ans=-inf


by Unknown__ @ 2024-07-26 16:03:52

@Paradox 大佬%%%


|