#K45832. Minimum Platforms for Trains
Minimum Platforms for Trains
Minimum Platforms for Trains
You are given the arrival and departure times of n trains at a railway station. Your task is to determine the minimum number of platforms required so that no train needs to wait because of the lack of a platform.
When a train arrives at time \(a_i\) and departs at time \(d_i\), the station must have a platform free at time \(a_i\) if no other train is departing at or before that time. Formally, you need to compute the maximum number of trains present at the station at any time, which can be represented as:
$$\text{platforms} = \max_{t}\{\text{number of trains at time } t\}.$$
This value represents the minimum number of platforms required to handle the schedule without any delay.
inputFormat
The input is read from stdin and has the following format:
- The first line contains an integer n, the number of trains.
- The second line contains n space-separated integers representing the arrival times.
- The third line contains n space-separated integers representing the departure times.
outputFormat
Print a single integer to stdout that denotes the minimum number of platforms required for the station.
## sample6
900 940 950 1100 1500 1800
910 1200 1120 1130 1900 2000
3