Meeting room Max. score: 50.00 Given N groups of people who want to have a meeting in…
- User
Meeting room Max. score: 50.00 Given N groups of people who want to have a meeting in the only meeting room in the office. Each group has people[i] people, who want to start the meeting at the starting[i] time and end it at the ending[i] time (both inclusive). No two groups can use the meeting room at the same time. If group / does not get the meeting room, then all the people[j] people cannot meet Calculate the minimum number of people that cannot meet if the meeting room is optimally assigned to groups. Note: Group i and j can get the meeting room one after the other if and only if end[i] < start[j]. Function description Complete the function solve. This function takes the following 4 parameters and returns the required answer: • N: Represents the number of groups • people[]: Represents the number of people in each group • starting]: Represents the starting time of their meetings • ending]: Represents the ending time of their meetings Input format for custom testing Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code. • The first line contains N denoting the number of groups. • The second line contains N space-separated integers denoting the number of people in each group. • The third line contains N space-separated integers denoting the starting time of each group's meeting. • The fourth line contains N space-separated integers denoting the ending time of each group's meeting. Output format Print a single integer representing the minimum number of people who cannot have a meeting. Constraints
1 <=N <= 10^5 2 <= people[i] <= 10^9 1 ≤ start[i] <= 10^9 1<= end[i] <= 10^9 start[i] <= end[i]
Sample input
5 4 3 5 6 10 12365 12577 Sample output 10 Explanation Given . N=5 people[] = [4, 3, 5, 6, 10] starting[] = [1. 2. 3. 6, 5] ending[] = [1, 2, 5, 77) Approach • Here the optimal way would be to first give the meeting room to the first group from 1 to 1 . Then give the meeting room to the second group from 2 to 2. Then give the meeting room to the third group from 3 to 5. • Then give the meeting room to the fourth group from 6 to 7. • We can't give the meeting room to both the third and fifth groups as they overlap. • So the total number of people that got the meeting room would be 4 - 3 + 5 + 6 = 18. . Therefore the answer would be -28 - 18 = 10. Note: Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Th must pass these hidden test cases to solve the problem statement. Limits Time Limit: 1.0 sec(s) for each input file Memory Limit: 256 MBcode:-
def solve(N, people, starting, ending): pass
- Assistant