P17276 [GeeksforGeeks] Bb917adb320fba36a9d68fd64c83ef322632a094
普及
题目描述

You are given n-platform and two main running railway tracks for both directions. Trains that need to stop at your station must occupy one platform for their stoppage and the trains which need not stop at your station will run away through either of the main track without stopping. Now, each train has three values first arrival time, second departure time, and the third required platform number. We are given m such trains you have to tell the maximum number of trains for which you can provide stoppage at your station.
Note: Trains are given in the form of {arrival time, departure time, platform Number} and the arrival time and departure time are represented by a 4-digit integer as 1030 will represent 10:30 and 912 will represent 09:12 (24 hour Clock).
Example 1:
Input : n = 3, m = 6
Train no.| Arrival Time |Dept. Time | Platform No.
1 | 10:00 | 10:30 | 1
2 | 10:10 | 10:30 | 1
3 | 10:00 | 10:20 | 2
4 | 10:30 | 12:30 | 2
5 | 12:00 | 12:30 | 3
6 | 09:00 | 10:05 | 1
Output : Maximum Stopped Trains = 5
Explanation : If train no. 1 will left
to go without stoppage then 2 and 6 can
easily be accommodated on platform 1.
And 3 and 4 on platform 2 and 5 on platform 3.
Your Task:
You don't need to read input or print anything. Your task is to complete the function maxStop() which takes two integers n no of platforms, m number of trains, and array trains[] as input parameter and returns an integer.
Expected Time Complexity: O(M*logM)
Expected Auxiliary Space: O(M)
Constraints:
1 <= N <= 100
1 <= M <= 10^{4}

输入格式

见题面

输出格式

见题面

样例输入
n = 3, m = 6 Train no.| Arrival Time |Dept. Time | Platform No. 1 | 10:00 | 10:30 | 1 2 | 10:10 | 10:30 | 1 3 | 10:00 | 10:20 | 2 4 | 10:30 | 12:30 | 2 5 | 12:00 | 12:30 | 3 6 | 09:00 | 10:05 | 1
样例输出
Maximum Stopped Trains = 5