Skip to content
C

Activity Selection

Mediumjavapythonccppjavascript

Given N activities with start and finish times, select the maximum number of activities that can be performed by a single person, where a person can only work on one activity at a time. An activity may start exactly when another finishes.

Input Format

The first line contains an integer N. Each of the next N lines contains two integers start and finish (start <= finish).

Output Format

Print the maximum number of non-overlapping activities.

Input (stdin)

Output

Run your code to see output here...