Getting NZEC error in RRCOPY problem

Not able to find any runtime error.Thisthe link to my code to the RRCOPY problem
http://www.codechef.com/viewsolution/6544974

In your solution, you were declaring array “a” and “b” in each testcase, this was the cause of RE. I have declared them globally, and it got accepted. Check here.

Ok,I got it. But why does my code gets NZEC error on not declaring the array globally:)

When a variable is declared inside a function (in your case, main), it’s allocated on the stack, and if it’s too large (e.g, a big array), you’ll encounter stack overflow.

A variable defined outside all functions is allocated statically. Its lifetime lasts until the program terminates.