TLE in bottom down DP on coins problem

#include
#include
#include
using namespace std;
int dp[1000][1000];

int solve(int N,int M, int *s){

memset(dp,-1,sizeof(dp));
if(N == 0) return 1; // we have found a denomination
if(N < 0) return 0; //no chnage can be found

if(M == 0) return 0;
if(dp[N][M] != -1) return dp[N][M];

int op1 = solve(N-s[0],M,s);
int op2 = solve(N,M-1,s+1);

return dp[N][M] = op1+op2;

}
int main(){
int N,M;
cin>>N>>M;
int s[M];
for(int i=0;i<M;i++) cin>>s[i];
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
dp[N][M] = -1;
}
}
cout<<solve(N,M,s);
}

Hey @Nikhil-Rajput-1327861567562217
Mentioned the changes in comments https://ide.codingblocks.com/s/392614