记录编号 406002 评测结果 AAAAAAAAAA
题目名称 天才魔法少女琪露诺爱计数 最终得分 100
用户昵称 Gravatarsxysxy 是否通过 通过
代码语言 C++ 运行时间 0.037 s
提交时间 2017-05-17 18:38:30 内存使用 1.34 MiB
显示代码纯文本
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cctype>
#include <list>
#include <queue>
#include <deque>
using namespace std;
namespace IO{
  char buf[1<<18], *fs, *ft;
  inline char readc(){
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<18,stdin)),fs==ft)?EOF:*fs++;
  }
  inline int readint(){
    char c; int r;
    while(c = readc()){if(c >= '0' && c <= '9'){r = c^0x30;break;}}
    while(isdigit(c = readc()))r = (r<<3)+(r<<1)+(c^0x30);
    return r;
  }
  inline int read_string(char *str){
    int len = 1;char c;
    while(!isalpha(c = readc()));str[0] = c;
    while(isalpha(c = readc()))str[len++] = c;
    str[len] = 0;
    return len;
  }
};using IO::read_string; using IO::readint;
const int MAXN = 1e5+10;
const int MAXT = 1e4;
const int MOD = 998244353;
int f[MAXN], H[MAXN];
int bits[MAXT+10];
inline void add(int p, int v){
  for(; p <= MAXT; p += p&-p)bits[p] = ((bits[p]+v)%MOD+MOD)%MOD;
}
inline int query(int p){
  int r = 0;
  for(; p; p -= p&-p)r = (r+bits[p])%MOD;
  return r;
}
int main(){
  freopen("cirnoisclever.in", "r", stdin);
  freopen("cirnoisclever.out", "w", stdout);
  int N, L, R, T;  
  N = readint(); L = readint(); R = readint(); T = readint();
  for(int i = 1; i <= N; i++)H[i] = readint();
  f[1] = 1;
  for(int i = L+1; i <= N; i++){
    add(H[i-L], f[i-L]);
    f[i] = (query(min(H[i]+T, MAXT))-query(max(1, H[i]-T)-1)+MOD)%MOD;
    if(i-R >= 1)add(H[i-R], -f[i-R]);
  }
  printf("%d\n", f[N]);
  return 0;
}