#C8635. Maximum Score Difference in Partitioned Rooms

    ID: 52639 Type: Default 1000ms 256MiB

Maximum Score Difference in Partitioned Rooms

Maximum Score Difference in Partitioned Rooms

You are given N participants, each having a score, and K rooms. The participants are first sorted by their scores in non-decreasing order. They are then assigned to the rooms in contiguous blocks such that each room gets \lceil N/K \rceil participants (except possibly the last room which might have fewer participants). The task is to calculate the maximum possible score difference within any room, where the score difference of a room is defined as the difference between the maximum and minimum scores in that room.

Note: The ceiling function \(\lceil N/K \rceil\) is computed as \(\frac{N+K-1}{K}\) in integer arithmetic.

inputFormat

The input is given via STDIN as follows:

  1. The first line contains two integers N and K, where N is the number of participants and K is the number of rooms.
  2. The second line contains N space-separated integers representing the scores of the participants.

outputFormat

Output a single integer to STDOUT which is the maximum score difference across all rooms.

## sample
6 3
100 200 300 450 500 750
250

</p>