kashyap's blog

By kashyap, 12 years ago, In English

can someone explain ABA12C or give tutorial for it?

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
12 years ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

It's almost classical "knapsack problem". Just google dp solution of knapsack problem. d[X][Y] = minimal possible cost to take X packets with total sum Y.

 for numOfPackets
   for totalWeight
     for weight
       d[numOfPackets + 1][totalWeight  + weight] = min(d[numOfPackets + 1][totalWeight  + weight],
                                                       d[numOfPackets][totalWeight] + cost[weight]);