#ABC472B. 折断木棍 / Break a Stick
折断木棍 / Break a Stick
Problem Statement
There is one stick. This stick has notches, which divide it into parts.
The lengths of the parts are in order from one end.
When choosing one notch and breaking the stick there to obtain two sticks, find the minimum possible absolute value of the difference between the lengths of the two resulting sticks.
Here, the width of a notch can be ignored, and the length of each resulting stick is the sum of the lengths of the parts it contains.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Output the answer.
4
5 2 3 8
2
Breaking the stick at each notch results in the following:
- Breaking at the first notch from the end results in two sticks of lengths and , with an absolute difference of .
- Breaking at the second notch from the end results in two sticks of lengths and , with an absolute difference of .
- Breaking at the third notch from the end results in two sticks of lengths and , with an absolute difference of .
7
31 41 59 26 53 58 97
51
10
67011 35764 33042 24098 63738 98760 17199 68579 21812 45408
28105
- Source: AtCoder ABC 472 B
相关
在下列比赛中: