Train Boarding
InterviewTime limit1sMemory limit1024 MB
Each passenger walks to the door at the center of the nearest car, breaking ties toward the higher-numbered car; report the longest walk and the busiest car's passenger count.
- Level
Easy3 of 10
- Topics
- Implementation, Math, Array, Simulation
- Solved
- No attempts yet
Problem
Punctual City is famous for the punctuality of its citizens and its public transportation. Its train system is especially well known. The trains are always on time and are never late or early. Statistics about train boarding are collected regularly to keep things running smoothly.
A train has cars numbered to (from front to back), each of length meters. Each car has exactly one boarding door, located at the center of the car ( meters from each end). There are no gaps between cars.
When the train stops at the boarding platform, each waiting passenger walks to the door of the car closest to them, choosing the higher numbered car when there is a tie.
Given the locations of the passengers relative to the train, help the city by finding the longest distance any passenger has to walk and the maximum number of passengers boarding a single car.

Input
The first line contains three integers (), (), and (). is the number of cars in the train, is the length of each car, and is the number of passengers waiting for the train. is guaranteed to be even.
The next lines give the locations of the passengers relative to the train. Each line contains a single integer (), which is the distance the passenger is behind the front end of the train.
Output
On the first line, output the longest distance any passenger has to walk. On the second line, output the maximum number of passengers boarding a single car.