Segmentation Fault Although Answer is Coming Correct

Answer : http://ide.geeksforgeeks.org/TIe2ve

my answer is coming correct in devc++ but in GeeksForGeeks it is showing segmentation fault

Question : http://www.geeksforgeeks.org/dynamic-programming-set-7-coin-change/

Your code isnt following input format.

It clearly says-

  1. In each test cases, the first line contains an integer ‘M’ denoting the size of array
  2. The second line contains M space-separated integers A1, A2, …, AN denoting the elements of the array.
  3. The third line contains an integer ‘N’ denoting the cents.

But you are taking input as-

 int v,n;//Assuming v is value?
    cin>>v>>n;
    int a[n];
    
    for(int i=0;i<n;i++)
    cin>>a[i];

You Are Great @vijju123

1 Like
//