Under construction

Still being built. Things may change

Train Boarding

Interview

Time limit1sMemory limit1024 MB

Summary
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 11 to NN (from front to back), each of length LL meters. Each car has exactly one boarding door, located at the center of the car (L/2L/2 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 NN (1≤N≤1001 \leq N \leq 100), LL (2≤L≤1002 \leq L \leq 100), and PP (1≤P≤1 0001 \leq P \leq 1\,000). NN is the number of cars in the train, LL is the length of each car, and PP is the number of passengers waiting for the train. LL is guaranteed to be even.

The next PP lines give the locations of the passengers relative to the train. Each line contains a single integer xx (0≤x≤10 0000 \leq x \leq 10\,000), 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.

Examples2

  1. Example 1

    Input
    68 90 6
    3809
    288
    2306
    2215
    4211
    379
    
    Expected output
    27
    1
    
  2. Example 2

    Input
    27 58 10
    823
    678
    799
    224
    349
    1002
    308
    978
    602
    265
    
    Expected output
    28
    1