Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

shank_punk's blog

By shank_punk, 12 years ago, In English

How do I solve This problem efficiently ?

  • Vote: I like it
  • +7
  • Vote: I do not like it

»
12 years ago, hide # |
← Rev. 2  
Vote: I like it +7 Vote: I do not like it

It's classical DP problem.

a[0] = true;
for (int i = 0; i < n; ++i)
   for (int j = W; j >= 0; --j)
      if (a[j]) a[j + w[i]] = true;