Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,w;
int a[201];
int dp[201][10001];
int mod=1000000007;

int main(void){
	scanf("%d%d",&n,&w);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	sort(a,a+n);
	reverse(a,a+n);
	dp[0][0]=1;
	for (int i=0;i<n;i++){
		memcpy(dp[i+1],dp[i],sizeof(dp[i]));
		for (int j=w-a[i];j>=0;j--){
			dp[i+1][j+w[i]]=(dp[i+1][j+w[i]]+dp[i][j])%mod;
		}
	}
	reverse(w,w+n);
	int all,res;
	all=res=0;
	for (int i=0;i<n;i++){
		for (int j=max(0,w-all-a[i]+1);j<=w-all-(i?a[i-1]:0);j++){
			res=(res+dp[n-i][j])%mod;
		}
		all+=w[i];
	}
	printf("%d\n",res);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:36: error: invalid types 'int[int]' for array subscript
   20 |                         dp[i+1][j+w[i]]=(dp[i+1][j+w[i]]+dp[i][j])%mod;
      |                                    ^
a.cc:20:53: error: invalid types 'int[int]' for array subscript
   20 |                         dp[i+1][j+w[i]]=(dp[i+1][j+w[i]]+dp[i][j])%mod;
      |                                                     ^
a.cc:30:23: error: invalid types 'int[int]' for array subscript
   30 |                 all+=w[i];
      |                       ^
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h: In instantiation of 'void std::reverse(_BIter, _BIter) [with _BIter = int]':
a.cc:23:9:   required from here
   23 |         reverse(w,w+n);
      |         ~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1089:63: error: no matching function for call to '__iterator_category(int&)'
 1089 |       std::__reverse(__first, __last, std::__iterator_category(__first));
      |                                       ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66,
                 from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note: candidate: 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&)'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator_base_types.h: In substitution of 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&) [with _Iter = int]':
/usr/include/c++/14/bits/stl_algo.h:1089:63:   required from 'void std::reverse(_BIter, _BIter) [with _BIter = int]'
 1089 |       std::__reverse(__first, __last, std::__iterator_category(__first));
      |                                       ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
a.cc:23:9:   required from here
   23 |         reverse(w,w+n);
      |         ~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~