Some test cases fails (Rainwater Harvesting)

tell me where i am doing wrong…
some test cases fails in Rainwater Harvesting problem.
Code Link:

@alok.maurya array size can be upto 10^6 but you have taken max size of your array as 1000.