Optimizing a DP problem

Revision en1, by theVPN, 2024-03-17 13:09:58

I have the following problem

Given an array of n integers called a (n <= 10^3 and |a[i]| <= 10^4). Given an integer M, count the number of increasing subsequenes such that the sum of their elements equal to M.

E.g: with the input

6 11

7 1 4 3 5 6

The results should be 2 since 2 subsequences (1,4,6) and (5,6) satisfy the conditions.

I have approached an algorithm that results in O(n^2*m) complexity. But still, I'm wondering is there an even better way to optimize this algorithm? Hopefully you guys can help me

Tags dp, array, optimization

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English theVPN 2024-03-17 13:09:58 555 Initial revision (published)