Painter problem doubt


plzz tell me where i am wrong

plzz check my code

firstly ur r is wrong
take example
n=4 k=3
1 1 2 100
wating time should be only 1 sec
but ur code make it bigger
Also due to large constraint ur code will also gave tle