Money change problem dp

please tell me my mistake
am getting run error
please help me

my code
https://ide.codingblocks.com/s/49708

question link
https://hack.codingblocks.com/contests/c/512/1026

thats because you have declared a two d array with size [n+1][amount] and returning the value as dp[n][amount] /// you are accessing the index which is out of bound

and also try to do this question in one d array

i cant understand 1 d dp approach given on geeks for geeks site
in my code am not able to declare a 2d array as big as required to cover the questions constraints
please can u give me a commented 1d dp code for this problem

ll int ans(int a[],int n,int value){

	    int dp[value+1];
	    for(int i=0;i<=value;i++)
	    dp[i]=0;
	    dp[0]=1;
	    for(int i=0;i<n;i++)
	    {
	        for(int j=a[i];j<=value;j++)
	        dp[j]=(dp[j]+dp[j-a[i]])%(1000000007);
	    }
 
return dp[value];

}