Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;
const int MAX_N=1e5,MOD=1e9+7;
const ll INF=(1e18)+4;

int N;
ll A[2];
ll S[MAX_N];

ll memo[MAX_N];
int next[MAX_N][2];
ll diff[MAX_N];

int st_size;
ll dat[MAX_N*4];

void init(){
	st_size=1;
	while(st_size<N-1) st_size<<=1;
	REP(i,st_size){
		dat[i+st_size-1]=INF;
	}
	REP(i,N-1){
		dat[i+st_size-1]=diff[i];
	}
	for(int i=st_size-2;i>=0;i--){
		dat[i]=min(dat[i*2],dat[i*2+1]);
	}
}

ll query(int s,int t,int k,int a,int b){
	if (s<=a && b<=t){
		return dat[k];
	}else if (t<=a || b<=s){
		return INF;
	}else{
		int m=(a+b)/2;
		return min(query(s,t,k*2+1,a,m),query(s,t,k*2+2,m,b));
	}
}

int dfs(int n){
	if (n==N){
		return 1;
	}
	if (memo[n]!=-1){
		return memo[n];
	}
	int res=0;
	REP(g,2){
		int ne=next[n][g];
		if (ne!=-1){
			res+=dfs(ne);
			res%=MOD;
		}
	}
	return res;
}

int main(){
	cin>>N;
	REP(i,2) cin>>A[i];
	REP(i,N){
		cin>>S[i];
	}
	REP(i,N-1){
		diff[i]=S[i+1]-S[i];
	}
	init();
	for(int n=N-1;n>=0;n--){
		REP(g,2){
			int lb=lower_bound(S,S+N,S[n]+A[g])-S;
			if (n+1<lb-1){
				int mdiff=query(n+1,lb-1,0,0,st_size);
				if (mdiff<A[(g+1)%2]){
					next[n][g]=-1;
					continue;
				}
			}
			if (lb==N){
				next[n][g]=N;
				continue;
			}
			int s=S[lb];
			if (n+1==lb){
				next[n][g]=n+1;
				continue;
			}
			if (S[lb-1]+A[(g+1)%2]<=s){
				next[n][g]=lb;
			}else{
				next[n][g]=next[lb-1][(g+1)%2];
			}
		}
	}
	memset(memo,-1,sizeof(memo));
	printf("%d\n",dfs(0));
	return 0;
}


Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:54:24: error: reference to 'next' is ambiguous
   54 |                 int ne=next[n][g];
      |                        ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:14:5: note:                 'int next [100000][2]'
   14 | int next[MAX_N][2];
      |     ^~~~
a.cc: In function 'int main()':
a.cc:79:41: error: reference to 'next' is ambiguous
   79 |                                         next[n][g]=-1;
      |                                         ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:14:5: note:                 'int next [100000][2]'
   14 | int next[MAX_N][2];
      |     ^~~~
a.cc:84:33: error: reference to 'next' is ambiguous
   84 |                                 next[n][g]=N;
      |                                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:14:5: note:                 'int next [100000][2]'
   14 | int next[MAX_N][2];
      |     ^~~~
a.cc:89:33: error: reference to 'next' is ambiguous
   89 |                                 next[n][g]=n+1;
      |                                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:14:5: note:                 'int next [100000][2]'
   14 | int next[MAX_N][2];
      |     ^~~~
a.cc:93:33: error: reference to 'next' is ambiguous
   93 |                                 next[n][g]=lb;
      |                                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:14:5: note:                 'int next [100000][2]'
   14 | int next[MAX_N][2];
      |     ^~~~
a.cc:95:33: error: reference to 'next' is ambiguous
   95 |                                 next[n][g]=next[lb-1][(g+1)%2];
      |                                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:14:5: note:                 'int next [100000][2]'
   14 | int next[MAX_N][2];
      |     ^~~~
a.cc:95:44: error: reference to 'next' is ambiguous
   95 |                                 next[n][g]=next[lb-1][(g+1)%2];
      |                                            ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:14:5: note:                 'int next [100000][2]'
   14 | int next[MAX_N][2];
      |     ^~~~