Getting WA for Corona Warriors

I am participating in the SemiFinal round of TechGig code Gladiators 2020. For the first problem, though the answer is passing on all the manual test cases, i am getting WA when submitted?

Link to the code :

Link to the question: Corona Warriors

For input 4 3
1 2 1 0
2 3 0 1
3 1 4 2

Output Should be 3
Your Output 4
p1 doctor 1
p2 doctor 3
p3 doctor 2
p4 doctor 2
total sum 3

But one doctor can only treat one contiguous subarray of patient right? Did i understood it wrongly?
Can a doctor treat more than one subarray of patients?

its failing all the test cases on Techgig. Any thoughts on that?

The main line in the problem is that doctors should treat consecutive patients.
So if 1to from doctor 1 to 2 then I can’t return back to doctor 1.This is the problem I’m having.
The general dp solution takes in count of all the doctors and gives the min.

Bro now you got it what to do

Can’t i use recursion ? As it will check all possibility and ansewer will be always right . and also constraint is i think low so that we can use recursion in iMO

But a doctor can treat atmost one consecutive group of patients? I have implemented that and it is still WA

I got the mistake that i did in my code, i am traversing linearly for all the doctors. Here we get the minimum when we traverse the doctors randomly. But i am not getting the point on how to get back to the doctor that we have left, or traverse the doctors randomly.

Yeah i got your point,once we leave the doctor we can’t get back to that doctor in a recursion.

Are we allowed to discuss problems, since the contest is live?

you got output???

You shouldn’t be discussing question from ongoing contest!