Queries regarding question

Could you explain to me the meaning of the statement that a painter could paint only the continues segment of the board, does this mean that more than one painter con paint on a board

Yes it is possible that one painter has completed of one work and started other board while other painter still paints his board. You can use binary search on this question. Worst case time taken would be equal to total area of all the boards.

For:
k=2 and n=5 where n: 1,2,3,4,5.
The answer will be 9.

for better understanding see this:

i am not able to pass the 4th and the 6th test case . could u please give some examples which would be similar to these test cases so that i could understand where my code would be giving the wrong answer

for test case:
4
6
99999 8999565 809950 1234999
123456 777777
you shoudl get
8999565