Run time error

I am consistently getting run time error please help me with my problem.
Here’s the link:
https://www.codechef.com/viewsolution/88315778

It may happen because you are wasting a lot of memory by declaring an array of size 50 but you got limited memory with which you must get the output.

try declaring the array as a[N] after taking the input of N, as it would make

2 Likes

This is because you are initializing the array (arr) of size 50.
you should do it like this.
scanf("%d", &N);
int arr[N];

2 Likes

Thank you guys.