SPOJ- HISTOGRA (Help needed)

Problem

I tried solving the above problem using divide and conquer[although an O(n) soln is possible]. I tried various test cases and all seemed to pass, but I am getting “WA” verdict. Here’s my solution. Kindly, help in finding the bug.

Thank you

Please check test case number #13 in this link: http://www.spojtoolkit.com/history/HISTOGRA.

7 Likes

The link says “File not found”.Can you please mention that test case in comments below. Thanks

Test case can be found here

8 Likes

Thanks for your help. As it is not easy to detect mistake from such large values [although I’ll try], can you suggest the mistake(if you found any). Thanks once again :slight_smile: