0PricingLogin
Competitive Programming Academy · Lesson

Fractional Knapsack by Ratio

Take the highest value-per-weight first.

The Knapsack Setup

You have items with a value and a weight and a bag of limited capacity. The goal is to carry the most total value you can. 🎒

Fractional Means Splittable

In the fractional version you may take a piece of an item, like half a sack of grain. This freedom is what lets greedy win here.

All lessons in this course

  1. The Greedy Mindset
  2. Activity Selection by Earliest Finish
  3. Fractional Knapsack by Ratio
  4. Spot When Greedy Fails
← Back to Competitive Programming Academy