Need help in " Anti-Subarray Sum " problem ( D ) of codechef  187 
Difference between en1 and en2, changed 42 character(s)
problem -> https://www.codechef.com/problems/ANTISM?tab=statement↵

In this problem, I know that a prefix and suffix approach can solve it, but I am struggling with the dynamic programming (DP) approach.↵
I have tried to understand many solutions that use 4D or 5D DP, but I still haven’t been able to grasp them.↵
Can anyone explain how to approach this using DP?↵

My recursive DP gives a TLE because it involves the sum of the subarray.↵
Here's the structure of my recursive function:↵



f(
i  i   , picked_first_element  , left_one_element_in_middle_after_picking,   ,   pick_one_ele_after_leaving_one_in_middle,   , ↵
  
 sum_of_ele_picked_right_now   , picked_anyone_ele_such_that_its_b[i]==1) {   ) {↵
    ↵

    // code accordingly↵

    // gives TLE due to "sum" variable↵


}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English aryan0707as 2025-05-23 06:26:38 42
en1 English aryan0707as 2025-05-23 06:24:54 813 Initial revision (published)