Help in DP Problem - C Two Arrays -Codeforces!

How to solve this problem using Dp ??? I read the editorial and found that it has been solved using combinatorics but I saw others have solved it using the Dp approach.

Problem Link -Problem - C - Codeforces

Please Help !!! Thanks in advance