madcannibal's blog

By madcannibal, history, 6 years ago, In English

is it possible to solve it by a recursive knapsack algorithm ? it take Time limit exceed when i memo it in 2d array , and if it is impossible how can i solve it by 1d subset sum ? thanks in advance :D

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

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

yes you can solve it by recursive knapsack with 2d array also .. i solve it and get AC here is my code : Uva 11658 — Best Coalitions

  • »
    »
    19 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    if(id != x — 1) res = min(res , solve(id + 1 , sum)); res = min(res , solve(id + 1 , sum + a[id]) + a[id]);

    can you please explain this portion ?

»
12 months ago, # |
  Vote: I like it 0 Vote: I do not like it

first to be noted.. Here more than 50% not equal to 50%. here is a code(**AC**) of mine. https://pastebin.ubuntu.com/p/f8W6pC6KVd/