#K61482. Minimum Number of Platforms

    ID: 31319 Type: Default 1000ms 256MiB

Minimum Number of Platforms

Minimum Number of Platforms

Trains arrive and depart from a railway station, and we need to allocate platforms such that no train has to wait.

Given two lists: one for arrival times and the other for departure times of n trains, determine the minimum number of platforms required so that every train can be accommodated without any delay.

The problem can be formulated as finding the maximum number of trains that are present at the station at the same time. Mathematically, if we denote the arrival times as \(A = [a_1, a_2, \dots, a_n]\) and departure times as \(D = [d_1, d_2, \dots, d_n]\), you need to compute the value:

\[ \text{Minimum Platforms} = \max_{\text{time}} (\text{number of trains at the station}) \]

Assume the times are given in a 24-hour integer format without colons (e.g., 900 for 09:00, 1800 for 18:00).

inputFormat

The input is read from standard input (stdin) and has the following format:

n
arrival[0] arrival[1] ... arrival[n-1]
departure[0] departure[1] ... departure[n-1]

Here, n is the number of trains. The second line contains n space-separated integers representing the arrival times, and the third line contains n space-separated integers representing the departure times.

outputFormat

Output a single integer to standard output (stdout), which represents the minimum number of platforms needed so that no train waits.

## sample
6
900 940 950 1100 1500 1800
910 1200 1120 1130 1900 2000
3