#K39027. Minimize Maximum Travel Time

    ID: 26329 Type: Default 1000ms 256MiB

Minimize Maximum Travel Time

Minimize Maximum Travel Time

Kayla needs to plan her stops along Pine Street, where she must visit a number of restaurants and customers located at various positions on a straight line. The goal is to minimize the maximum travel time between any two successive stops. The travel time between two stops is defined as the distance between them. Formally, given the coordinates (x_1, x_2, \ldots, x_n) sorted in increasing order, you must compute (\max_{1 \leq i < n} (x_{i+1} - x_i)). Note that the stops include both restaurants and customers.

Input Constraints:

  • \(E\) - the number of restaurants.
  • \(C\) - the number of customers.
  • A list of \(E\) integers indicating the positions of restaurants.
  • A list of \(C\) integers indicating the positions of customers.
Your task is to compute and output the minimal possible maximum travel time between two successive stops after merging the two lists of positions and sorting them in non-decreasing order.

inputFormat

The input is given via standard input (stdin) as space separated integers in the following format:

(E) (C) (r_1) (r_2) ... (r_E) (c_1) (c_2) ... (c_C)

where (E) and (C) denote the number of restaurants and customers respectively, followed by the coordinates of restaurants and then customers.

outputFormat

The output should be printed to standard output (stdout), and it consists of a single integer representing the minimum possible maximum travel time (i.e. the maximum difference between any two successive stops in the merged and sorted list).## sample

2 3 3 8 2 5 9
3