比赛 |
2024暑假C班集训9 |
评测结果 |
AAWWWWWWWW |
题目名称 |
天才魔法少女琪露诺爱计数 |
最终得分 |
20 |
用户昵称 |
┭┮﹏┭┮ |
运行时间 |
0.003 s |
代码语言 |
C++ |
内存使用 |
3.44 MiB |
提交时间 |
2024-07-09 08:48:24 |
显示代码纯文本
#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;}
ll ask(int x){
if(x <= 0)return 0;
ll ans = 0;
for(;x > 0;x -= lowbit(x))ans += c[x];
return ans;
}
ll ask(int l,int r){return ask(r) - ask(l-1);}
}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));
}
printf("%lld\n",f[n]);
return 0;
}