Segmentation Fault Although Answer is Coming Correct

Answer :

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

Question :

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?
    int a[n];
    for(int i=0;i<n;i++)

You Are Great @vijju123

1 Like