记录编号 590039 评测结果 AAAAAAAAAA
题目名称 天才魔法少女琪露诺爱计数 最终得分 100
用户昵称 Gravatar┭┮﹏┭┮ 是否通过 通过
代码语言 C++ 运行时间 0.004 s
提交时间 2024-07-09 14:45:47 内存使用 3.44 MiB
显示代码纯文本
#include <bits/stdc++.h> 
using namespace std;
#define ll long long
const int N = 5e5+10,M = 1e4;
const ll mod = 998244353;

ll read(){
    ll x = 0,f = 1;char c = getchar();
    for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
    for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
    return x * f;
}


int n,L,R,T,l,r;
ll f[N],s[N];

struct BIT{
    ll c[N];
    int lowbit(int x){return x & (-x);}
    void add(int x,ll val){for(;x <= M;x += lowbit(x))(c[x] += val + mod) %= mod;}
    ll ask(int x){
        if(x <= 0)return 0;
        ll ans = 0;
        for(;x > 0;x -= lowbit(x))(ans += c[x]) %= mod;
        return ans;
    }
    ll ask(int l,int r){return ((ask(r) - ask(l-1)) % mod + mod) % mod;}
}t;

int main(){
    freopen("cirnoisclever.in","r",stdin);
    freopen("cirnoisclever.out","w",stdout);
    n = read(),L = read(),R = read(),T = read();
    for(int i = 1;i <= n;i++)s[i] = read();
    f[1] = 1;
    l = 1,r = 0;
    for(int i = 2;i <= n;i++){
        while(r + 1 <= i - L)r++,t.add(s[r],f[r]);
        while(l < i - R)t.add(s[l],-f[l]),l++;
        (f[i] += t.ask(max(1ll,s[i] - T),min((ll)M,s[i] + T)) % mod) %= mod;
    }
    printf("%lld\n",f[n]);
    
    
    
    return 0;
    
}