TOP-DOWN V/s BOTTOM-UP

Revision en1, by JacobianDet, 2018-10-29 21:00:22

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.com/contest/1068/problem/D

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

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

Tags dp

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English JacobianDet 2018-10-29 21:00:22 562 Initial revision (published)