https://www.codechef.com/CODG2021/problems/CODIGO04

could you guys help me to explain the solution for the above problem?

Please refer to this:

can you explain the logic in brief?

Refer to comment in the linked thread:

The possible splitings with size i=valid solutions of size i-1( where last element was not included in previous adjacent subarray) +no valid solutions when we add the last element to previous sub array( = valid solutions of size i-1 - no solutions where last sub array was size k , which was dp[i-k-1] )

Please ask which part is not clear.

Where is editorial for this question?