Home / Expert Answers / Computer Science / please-write-the-code-in-python-and-take-input-in-input-txt-file-and-output-in-output-txt-task-2-pa849

(Solved): PLEASE WRITE THE CODE IN PYTHON AND TAKE INPUT IN INPUT.TXT FILE AND OUTPUT IN OUTPUT.TXT. Task 2 [ ...



PLEASE WRITE THE CODE IN PYTHON AND TAKE INPUT IN INPUT.TXT FILE AND OUTPUT IN OUTPUT.TXT.

student submitted image, transcription available below

student submitted image, transcription available below
Task 2 [10 Marks] Given \\( \\mathrm{N} \\) tasks and \\( \\mathrm{M} \\) people, where each task has a start time and end time, implement a greedy algorithm to find the maximum number of tasks that can be completed by M people. Each task can only be completed by one person and a person can only be assigned one task at a time. Two tasks cannot be completed simultaneously by the same person. Input The input consists of two integers \\( N \\) and \\( M(1 \\leq N, M \\leq 10 \\wedge 3) \\), the number of activities and the number of people, respectively. This is followed by \\( N \\) lines representing the activities. Each line contains two integers \\( S_{i} \\) and \\( E_{i}\\left(0 \\leq S_{i} \\leq E_{i} \\leq 10^{\\wedge} 9\\right) \\), representing the start and end times of the activity, respectively. Output Output a single integer representing the maximum number of activities that can be completed.\r\nSample Input/Output:


We have an Answer from Expert

View Expert Answer

Expert Answer



We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe