Painter Problem doubt1

Only two test cases are showing correct answer, rest are showing W.A. Please help.

@Rooopak_Sharma
Use long long int for your entire code instead of int and your code works fine.