SPOJ- HISTOGRA (Help needed)


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.


Test case can be found here


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

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: