#P14665. [KenOI 2025] 序列题
[KenOI 2025] 序列题
Description
Given a sequence of positive integers. Now you can perform one of the following operations up to times:
- Increase each number in the range by .
- Decrease each number in the range by .
You can independently select and in each operation.
Let be the maximum value of the sequence, and be the minimum value after the operations.
Find the minimum possible value of .
Input Format
The first line contains two integers, and .
The second line has numbers, and the - number is .
Output Format
One single number, the minimum possible value of .
5 2
1 2 3 4 5
2
Hint
Example explanation
We can increase each number in and by to make the sequence , . It can be proven that no better solution exists.
Data Volume and Conventions
This problem is divided into subtasks. Your score in a subtask is the minimum score across all its test cases.
This problem uses subtask dependencies. You will not receive the score for a subtask unless you achieve full points on all its dependent subtasks.
| Subtask | Special Properties | Score | Dependencies | ||
|---|---|---|---|---|---|
| none | none | ||||
| A | none | ||||
| none | |||||
Special property A: .
For all of the cases, .
Bonus: . Contestants who have solved all problems (AK) are welcome to continue exploring.
京公网安备 11011102002149号