Language: C++

#include <iostream>
#include <cstring>
#include <algorithm>
#define MOD 1000000007
using namespace std;

long long int n, k, arr[101], dp[101][100001], pre[101][100001], top=0;

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		top+=arr[i];
	}
	sort(arr, arr+n);
	for(int i=0;i<=min(k, arr[0]);i++){
		dp[0][i]=1;
		pre[0][i]=i+1;
	}
	long long int ek=arr[0];
	for(int i=1;i<n;i++){
		dp[i][0]=1;
		pre[i][0]=1;
		for(int j=1;j<=min(arr[i]+ek, k+1);j++){
			if(j-arr[i]-1>-1)
				dp[i][j]=(pre[i-1][min(j, ek)]-pre[i-1][j-arr[i]-1]+MOD)%MOD;
			else 
				dp[i][j]=pre[i-1][min(j, ek)];
			pre[i][j]=(dp[i][j]+pre[i][j-1])%MOD;
		}
		if(ek+arr[i]<=k)
			ek+=arr[i];
	}
	cout<<dp[n-1][k];
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:55: error: no matching function for call to 'min(int&, long long int&)'
   29 |                                 dp[i][j]=(pre[i-1][min(j, ek)]-pre[i-1][j-arr[i]-1]+MOD)%MOD;
      |                                                    ~~~^~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:29:55: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   29 |                                 dp[i][j]=(pre[i-1][min(j, ek)]-pre[i-1][j-arr[i]-1]+MOD)%MOD;
      |                                                    ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:29:55: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |                                 dp[i][j]=(pre[i-1][min(j, ek)]-pre[i-1][j-arr[i]-1]+MOD)%MOD;
      |                                                    ~~~^~~~~~~
a.cc:31:54: error: no matching function for call to 'min(int&, long long int&)'
   31 |                                 dp[i][j]=pre[i-1][min(j, ek)];
      |                                                   ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:31:54: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   31 |                                 dp[i][j]=pre[i-1][min(j, ek)];
      |                                                   ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:31:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |                                 dp[i][j]=pre[i-1][min(j, ek)];
      |                                                   ~~~^~~~~~~