CPKit
v1.6.1

Activity Selection

GreedyEasy

Select the maximum possible compatible activities scheduling.

Alt+Shift+A

Configuration Panel

Sorted Activity Selection Timeline (Track 0 selected, Track 1 discarded)

Timeline is empty.

Time Complexity

O(N log N) sorting + O(N) linear sweep

Space Complexity

O(N) mapping storage sizes
Conceptual Overview

The Activity Selection problem selects the maximum number of mutually compatible activities that can be performed by a single person or resource, assuming start and end times are given.

Greedy Choice Property

Always select the next compatible activity that finishes earliest (end time is minimized), leaving the maximum time remaining for subsequent activities.

Optimal Substructure

If we select activity A1 with earliest finish time, the optimal global solution consists of A1 plus the optimal solution to the subproblem of activities starting after A1 finishes.

Proof Idea / Correction

Proof by contradiction / exchange argument: suppose another optimal choice does not select the earliest finishing activity. Replacing its first activity with the earliest finishing one cannot increase overlaps, preserving optimality.

Source: CP-Algorithms greedy reference