Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

Items (value, weight) = (60, 10), (100, 20), (120, 30) can be split fractionally. With capacity 50, what is the maximum total value?

  1. A. 220
  2. B. 241
  3. C. 200
  4. D. 240

Correct answer: D. 240

Fractional knapsack is solved greedily by value-to-weight ratio; the first two items fill 30 units with value 160 and the rest of the capacity takes two-thirds of the third item's value 80 or the answer of 240.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic