JacobianDet's blog

By JacobianDet, history, 6 years ago, In English

Recently in a contest there was a DP problem which used a prefix-sum concept. I tried to implement it in bottom-up as well as in top-down. The bottom-up one got AC'ed but the top-down got a TLE on Test 3. I understand the reason for TLE but I am not able to implement that bottom-up prefix idea for this. Any ideas on how to solve the problem using top-down approach?

Problem link = http://codeforces.me/contest/1068/problem/D

Top-Down solution = https://pastebin.com/VYsA7cXj

Bottom-up solution = https://pastebin.com/5RryJeh5

Tags dp
  • Vote: I like it
  • +15
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

You can add 1 more DP for calculating prefix sum http://codeforces.me/contest/1067/submission/44793804

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks for this idea. It worked. Btw is there a formal method on the usage of simultaneous DP functions to solve a problem.