记录编号 599515 评测结果 AAAAAAAAAA
题目名称 [東方S1] 琪露诺 最终得分 100
用户昵称 Gravatarflyfree 是否通过 通过
代码语言 C++ 运行时间 0.430 s
提交时间 2025-03-18 22:13:59 内存使用 11.70 MiB
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pir pair<ll,ll>
#define ls first
#define rs second
#define mp make_pair
#define mod
#define MAXN 200010
#define qmod(x) (x>mod?x-mod:x)
inline ll read(){
    ll x = 0,f = 1;
    char c = getchar();
    while(c < '0'||c > '9'){
        if(c == '-')f = -1;
        c = getchar();
    }
    while(c >= '0'&&c <= '9'){
        x = x*10+c-'0';
        c = getchar();
    }
    return x*f;
}
struct node_sgt{
    ll l[MAXN*4],r[MAXN*4],maxz[MAXN*4],max_id[MAXN*4];
    void push_up(ll now){
        if(maxz[now << 1] > maxz[now << 1 | 1]){
            maxz[now] = maxz[now << 1];
            max_id[now] = max_id[now << 1];
        }else{
            maxz[now] = maxz[now << 1 | 1];
            max_id[now] = max_id[now << 1 | 1];
        }
    }
    void build(ll lz,ll rz,ll now){
        l[now] = lz;
        r[now] = rz;
        maxz[now] = -1e18;
        if(lz == rz){
            max_id[now] = lz;
            return;
        }
        ll mid = (lz + rz) >> 1;
        build(lz,  mid, now << 1);
        build(mid + 1, rz, now << 1 |1);
    }
    void modify(ll pos, ll val, ll now){
        if(l[now] == r[now]){
            maxz[now] = val;
            return;
        }
        ll mid = (l[now] + r[now]) >> 1;
        if(pos <= mid)modify(pos, val, now << 1);
        else modify(pos, val, now << 1 |1);
        push_up(now);
    }
    pir get(ll lz, ll rz, ll now){
        if(l[now] >= lz && r[now] <= rz){
            return mp(maxz[now], max_id[now]);
        }
        ll mid = (l[now] + r[now]) >> 1;
        if(lz <= mid){
            if(rz > mid){
                pir a = get(lz, rz, now << 1);
                pir b = get(lz, rz, now << 1 |1);
                if(a.ls >= b.ls)return a;
                else return b;
            }else return get(lz, rz, now << 1);
        }else return get(lz, rz, now << 1 | 1);
    }
}sgt;



ll dp[MAXN],pre[MAXN],a[MAXN];
ll n,L,R;
vector <ll> ans;
int main(){
    freopen("iceroad.in", "r", stdin);
    freopen("iceroad.out", "w", stdout);
    n = read(),L = read(),R = read();
    sgt.build(1, n + 2, 1);
    a[1] = max(read(), 0ll);
    dp[1] = a[1];
    sgt.modify(1, dp[1], 1);
    for(int i = 2;i <= n + 1; ++i){
        // a[i] = max(read(), 0ll);
        a[i] = read();
        if(i <= L)continue;
        pir res = sgt.get(max(1ll, i - R), i - L , 1);
        dp[i] = res.ls + a[i];
        pre[i] = res.rs;
        sgt.modify(i, dp[i], 1);
    }
    pir res = sgt.get(max(n + 1 - R, 1ll), n + 1, 1);
    dp[n + 2] = res.ls;
    pre[n + 2] = res.rs;
    ll now = n + 2;
    cout << dp[n + 2] << endl;
    while(now > 0){
        ans.push_back(now);
        now = pre[now];
    }
    for(int i = ans.size() - 1;i >= 0; --i){
        if(ans[i] > n + 1)cout << "-1 ";
        else cout << ans[i] - 1 << " ";
    }
    return 0;
}