How to use lower_bound in pair<int,int>p[] for solving activity selection problem

#include<iostream>
using namespace std;

int main(){
    int t;
    cin>>t;
     int n;
    while (t--)
    {
       
        cin>>n;
        pair<int,int> p[n];
        for (int i = 0; i < n; i++)
        {
            cin>>p[i].first;
            cin>>p[i].second;
        }
        
       
    }
    
    return 0;
}

Hey @sagar_aggarwal
Go through this : https://www.google.com/amp/s/www.geeksforgeeks.org/implementation-of-lower_bound-and-upper_bound-in-vector-of-pairs-in-c/amp/ and try to implement on ur own first

If u need any help then let me know

1 Like

By the way
You have to Sort the activities in the increasing order of ending times and then do a single traversal and pick up activities greedily, i.e, choose an activity whenever possible.

There is no need to apply Lower bound ot upper bound

1 Like

i am learning implementation through this problem i have alreay solved it by sorting and doing traversal after that

Oh alright ,let me know if u face any issue in that way
I might check tomorrow morning now :slight_smile:

1 Like

@Kartikkhariwal1 no worries i will try once if any issue will arrise i will ping :slight_smile: Good night

1 Like