Question: I need c++ code for this question Q3: Course Selection Problem X-land has a very famous university. The university offers N courses. Each course runs
I need c++ code for this question
Q3: Course Selection Problem X-land has a very famous university. The university offers N courses. Each course runs for some consecutive range of days. You are given starting and ending days of the i course by starts and endi, respectively. Sam wanted to enrol himself in the university. But he is not sure about the exact time for which he wants to study. Though he has Q such tentative plans in his mind. Each plan consists of a start date plan_start, and an end date plan end. Sam wants your help in finding out the maximum number of courses he can complete during cach of his plans. Note that at a time, Sam can not handle multiple courses, i.e. he can attend at most one course during a day. Also, a course will be considered completed only if Sam attends all the classes of the course Input There is a single test case. The first line of the input contains two space-separated integers N and Q denoting the number of courses the university offers and the number of plans Sam has in mind, respectively. The i of the next N lines contains two space-separated integers start and end denoting the starting and the ending day of the i* course. The j of the next Q lines contains two space-separated integers plan_start; and plan_endj, denoting the start and the end day of Sam's plan. Output Output Q lines - each containing an integer corresponding to the maximum number of the courses Sam can complete in the corresponding planned visit. Example Output: Input: 33 13 5 6 24 16 ON 23
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
