#P10205. [JOI 2024 Final] 室温 / Room Temperature
[JOI 2024 Final] 室温 / Room Temperature
Problem Description
Chairman K is responsible for adjusting the room temperature for the executives. He wants them to work as comfortably as possible.
There are executives in the room. Each executive is assigned an ID from to . Without wearing a coat, executive has a comfortable temperature of degrees. Also, for each coat an executive wears, their comfortable temperature decreases by degrees. That is, if executive wears coats, then executive 's comfortable temperature becomes degrees.
If the room temperature is degrees and an executive's comfortable temperature is degrees, then this executive's discomfort is , where denotes the absolute value of . Each executive will, depending on the room temperature, wear an appropriate number of coats to minimize their discomfort.
Chairman K defines the maximum discomfort among all executives as the room's discomfort, and he decides to set the room temperature to a value that minimizes the room's discomfort. However, the chosen temperature must be an integer.
Given the information about the executives and their comfortable temperatures, write a program to find the minimum possible value of the room's discomfort.
Input Format
The first line contains two integers .
The second line contains integers separated by spaces.
Output Format
Output one integer on a single line, representing the minimum possible value of the room's discomfort.
2 4
19 24
1
3 1
21 19 23
0
6 8
24 22 21 25 29 17
2
Hint
For all input data, the following constraints hold:
The detailed additional constraints and scores for each subtask are shown in the table below.
| Subtask | Additional Constraints | Score |
|---|---|---|
| 1 | 15 | |
| 2 | 5 | |
| 3 | 30 | |
| 4 | 35 | |
| 5 | No additional constraints | 15 |
Translated by ChatGPT 5