ADADET: In some cases the rightmost building is one less than the actual answer

help
adadet
cook83
help_please

#1

I know my code is O(n^3) but still please tell me why in most cases the actual answer matches with mine and in some my answer is 1 less than the actual answer. i think there is a minor error in my code.

Link to my code:


#2

Same Here. I Tried My Code on many different test-cases , all passing but on submission WA. Link to my Submission : https://www.codechef.com/viewsolution/14304164