adarsh000321's blog

By adarsh000321, history, 7 years ago, In English

In this spoj problem https://www.spoj.com/HSPLARCH/problems/HS08AKP/ constraints are bigger i.e., we cannot use 2D Knapsack so how else can we print the solutions in space optimized knapsack? Help would be greatly appreciated... :)

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

»
7 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Still waiting for someone to answer... :(

»
7 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

let f[I] mean the best value with a total weight I. We can maintain g[I] which means the origin of f[I], so that i — g[I] is the weight of current item and f[I] — f[g[I]] is the value. Then let I become j, and do so.

»
7 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it