Chef and soccer help

though the ediorial of chef and soccer of march challenge was explained in detail but i searched for people’s solution to find an easy solution to the problem.
But i’m not able to understand this easy solution that i came across. Can anyone explain this solution or any dp solution that does not involve finding nearest 1 to the right like in the editorial. Thanks.

That is really a nice dp problem I solved. And it is tough. I don’t think an easy solution exists… I’ll write an editorial on it :slight_smile: