Practice: Greedy methods
0 of 4 solved
About these problems
Apply, Connect, Reason and Stretch describe difficulty within this topic, not an official contest rating. Open any problem in any order; reading the chapter first is optional.
- 1Compatible sessionsThere are n sessions. A session with start s and end e occupies the time interval [s, e), which includes s but not e, so a session ending at time t is compatible with one starting at time t. Find the maximum number of sessions you can choose so that no two chosen sessions overlap.ApplyNot started
- 2Two-seat boatsThere are n people, and person i weighs ai. Each boat carries at most two people whose total weight is at most w. Every person fits in a boat alone. Find the minimum number of boats needed to carry everyone.ConnectNot started
- 3Covered timeThere are n time intervals. An interval with start s and end e is [s, e): it includes s but not e and has length e - s. Find the total length of time covered by at least one interval; time covered by several intervals counts only once.ReasonNot started
- 4Meeting coordinateThere are n points at integer coordinates a1, a2, ..., an on a line. Choose an integer x; the total distance is |a1 - x| + |a2 - x| + ... + |an - x|. Print the smallest possible total distance; you do not need to print x.StretchNot started