Блог пользователя NguyenKhacTrung

Автор NguyenKhacTrung, история, 9 месяцев назад, По-английски

i have the problem knapsack has condition N<=100 and w,v<=10^9.

  • Проголосовать: нравится
  • +7
  • Проголосовать: не нравится

»
9 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Any other condition specified? Probably there's.

»
9 месяцев назад, # |
Rev. 2   Проголосовать: нравится +14 Проголосовать: не нравится

This one has a extra condition $$$w\times v\le 10^9$$$, and I don’t think the problem is solvable without this condition.

»
9 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Could you please add the link? Or the full statement?

»
9 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

The problem probably has some other stuff if it is meant to be solvable with this range of values. The best you can do with a small $$$N$$$ would be "meet in the middle", which will still be a TLE if your $$$N \leq 100$$$

»
9 месяцев назад, # |
  Проголосовать: нравится -10 Проголосовать: не нравится

Vip pro ngừi Việt. As far as i know there's a solution with $$$O(n\sqrt{totalweight})$$$ complexity. So with $$$totalweight=n*w= 1e11$$$ then yeah this solution passes. The idea is that there are about $$$\sqrt{w}$$$ possible sums of subsets when the sum of all of the elements in the set equal $$$w$$$ so we just need to calculate all those possible sums first, then apply the general dp algorithm -> $$$O(n\sqrt{sum})$$$ instead of $$$O(n*sum)$$$. How? I havent implemented it myself but this blog exlains it well and also provides an implementation :D https://codeforces.net/blog/entry/97396

»
9 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can you add a link to the problem?