atcoder#ARC100B. [ABC102D] Equal Cut
[ABC102D] Equal Cut
Score : points
Problem Statement
Snuke has an integer sequence of length .
He will make three cuts in and divide it into four (non-empty) contiguous subsequences and . The positions of the cuts can be freely chosen.
Let be the sums of the elements in , respectively. Snuke is happier when the absolute difference of the maximum and the minimum among is smaller. Find the minimum possible absolute difference of the maximum and the minimum among .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Find the minimum possible absolute difference of the maximum and the minimum among .
5
3 2 4 1 2
2
If we divide as , then . Here, the maximum and the minimum among are and , with the absolute difference of . We cannot make the absolute difference of the maximum and the minimum less than , so the answer is .
10
10 71 84 33 6 47 23 25 52 64
36
7
1 2 3 1000000000 4 5 6
999999994