Блог пользователя WALL-E__

Автор WALL-E__, история, 8 лет назад, По-английски

i am having problem in solving this problem using 0/1 knapsack problem. http://codeforces.me/contest/19/problem/B

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

»
8 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

You need to keep two states:

I: Current item.

R: Number of items remaining.

The transition is, take the item I paying ci and go to the item I + 1 with R - 1 - ti remaining items, or dont take the item I and go to the item I + 1 with R remaining items.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится

There's a simple solution that runs in O(2N). Just try all combinations and keep the best.

»
8 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится -6 Проголосовать: не нравится

Another way is [itemupto][time] with observation time > 2000 dont matter. do we store dp[item][time] = minimum cost.

Note that for each item we can "add" 1 second to it because it takes care of itself.

And we us the dp table to solve problem.

EDIT: Wow it seems I've greatly infected the integrity of CF by giving out correct solutions! The horror!