Activity Selection (Contest)
Activity Selection easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Activity Selection easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement :
You are given N activities with their start and finish times as S and F. Find the maximum number of activities that can be performed by a single person, assuming that a person can only work on a single activity at a time. Input The first line of input contains one integer denoting N. Next N lines contain two space-separated integers denoting the start time and finish time for the ith activity.
Constraints 1 ≤ N ≤ 10^6 1 ≤ S[i] <= F[i] ≤ 10^9 Output Output one integer, the maximum number of activities that can be performed Example Sample Input 6 1 2 3 4 1 6 5 7 8 9 5 9
Sample Output 4
Explanation:- He can perform activity 1 2 4 5
Sample Input:- 4 4 6 5 6 3 5 6 8
Sample Output:- 2
link: