Segmentation fault

Getting segmentation fault. Not able to declare big size array.

Link to code - https://ide.codingblocks.com/s/415249

The input actually doesn’t consist of that much size, so declare the array dynamically.
Here is the working code https://ide.codingblocks.com/s/415252

Range of Numbers N and M can be between -1000000000 to 1000000000, input is given right ? I need the array size to accommodate thisis

Yeah but the actual testcases don’t have that N has input. Such a large size array is not possible.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.