Rain water harvesting

Why my program is not running for test cases 6,7 and 8 . if this is because N<=10^6 then how should i do that because for an array of 10^6 elements give segmentation fault

Hello @hrithikvohra505 you are not making array of size 10^6 and make all arrays a globally:
check this corrected code:

Sir why it is not working on local arrays i mean i tried using local arrays of 10^6 size but it was showing segmentation fault

@hrithikvohra505 because main is not handle three arrays of this size simultaneously.
We have to then declare it globally.

1 Like

what happens if i would have been doing a question with test cases then it would be diificult to use a global variable for all the test cases

@hrithikvohra505 if there would be test cases for that also it wouldnt have creater issue because everytimt you will take input for newer test case and check for the given n of that test case.

1 Like

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.