Painter Problem

I am not able to pass the last 2 test cases. I am not able to find any errors in it.

Hey @nikhil015
Please share your code.

Sorry, I forgot to add my code link. Here is the code link:

Hey I am not able to debug but your answer is overflowing for sure ,there can’t be any other reason .
So try using time_taken variable at last instead of using it in the starting .

You mean multiply time_taken variable with ans variable at the end.

yes @nikhil015 that is what I meant

I tried this but still not able to pass last 2 test cases. Here is the code please look into this.

Hey @nikhil015
You don’t have to sort the array.
You answer was working so dat becase the input arrays are sorted. But in last 2 case its not and sorting them will give u WA.
Also take start as max element of array.

thanks @Kartikkhariwal1 Finally I passed all my test cases. But still I don’t know why sorting results into Wrong Answer. If you explain me it would be very helpful. Thanks.

Saye we have array as 2 3 1
And painters =2
So painter 1 will work on 2 and painter 2 will work on (3+1)
But if we sort then 1 2 3
Painter 1 will work on 1+2
And painter 2 will work on 3
See in both answer is different

Painters can paint contiguous s work only