adarsh000321's blog

By adarsh000321, history, 5 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

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

Still waiting for someone to answer... :(

»
5 years ago, # |
  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.

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

    Oh I submitted your idea ... it got an ac on 2nd try... Thanks But i think the test cases are weak tooo...

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

      Hy..ik it's been too long but by any chance can you share the source code ?!

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