WESTAND Need help (DP hard)

I am trying to solve WESTAND problem from DEC-17 long Challenge. There is no editorial for this problem and the solutions submitted are not helping either. Can someone share their approach or share some idea on how to solve this problem?

I am referring to these solutions:

  1. CodeChef: Practical coding for everyone

  2. CodeChef: Practical coding for everyone

  3. CodeChef: Practical coding for everyone

I have not gone through the question yet, but this might help: link

i have read it, its still not very clear