#P11797. 【MX-X9-T1】『GROI-R3』Another Me
【MX-X9-T1】『GROI-R3』Another Me
Background
A huge repulsive force strikes. Your whole body seems to split into transparent fragments.
In the mirror there is a blurry figure. Is it “you”? Or is it just an illusion? There is no way to know. You want to move forward, but the other side retreats with extreme coordination. When you step back, the other side catches up again.
There is no energy left to support you to keep thinking. But toward that faint light source in the center of the prism, no matter what, you want to get a little closer. Also, there is the other “you” on the opposite side......
Problem Description
Given an integer sequence of length . You may perform any number of operations (including zero). In each operation, you must choose one of the following two types:
- Global increment by : for every , increment by .
- Global decrement by : for every , decrement by .
You want to minimize after the operations, i.e., minimize the maximum value among all , where denotes the absolute value of . You only need to compute this minimized value.
Input Format
The first line contains a positive integer .
The second line contains integers , describing the given sequence.
Output Format
Output one line containing one integer, the minimum possible value of .
5
-5 -2 0 2 3
4
6
1 -1 4 5 -1 4
3
18
9 9 8 2 4 4 3 5 3 0 9 0 2 2 8 1 1 5
5
Hint
Sample Explanation #1.
You only need to apply one global increment by to obtain . Then $\lvert a_1 \rvert, \lvert a_2 \rvert, \lvert a_3 \rvert, \lvert a_4 \rvert, \lvert a_5 \rvert$ are respectively, and the maximum is . It can be proven that is the minimum value you can achieve.
Constraints.
| Test Point ID | Special Property | ||
|---|---|---|---|
| A | |||
| B | |||
- Special Property A: is guaranteed to be even, and for every integer satisfying , .
- Special Property B: is guaranteed.
For of the testdata, it is guaranteed that and .
Translated by ChatGPT 5