Activity selection problem

sir i am not able to understand how to approach this problem.I mean i know i need to use pair function but in pair do we need to make as many arrays as the no of activity ,and then how are we going to store it .

sir I did this question using two arrays .getting the right answer but test case is not passing .
please look into it

Hi @Megha2468
first of all, you can make a vector<pair<int, int>> to store the timings.
sort the activities in the increasing order of their finishing times. Initially, we choose the first activity. Now, starting from second activity, current activity can be selected if the finish time of previous selected activity is less than or equal to the starting time of current activity.