#P12545. [UOI 2025] Partitioning into Three
[UOI 2025] Partitioning into Three
题目描述
There are non-negative integers arranged in a circle. The neighboring numbers in the circular order are and , and , , and , and .
Partition these numbers into three non-empty groups such that each number belongs to exactly one group, the numbers in each group are consecutively arranged in a circle, and the difference between the maximum and minimum sums of the numbers in the groups is minimized.
输入格式
The first line contains one integer --- the number of arranged numbers.
The second line contains non-negative integers --- the numbers arranged in a circle.
输出格式
In the first line, output one integer --- the difference between the maximum and minimum sums of the numbers in the groups in the optimal partition.
In the second line, output three integers , , --- such indices that the optimal partition of the numbers into three groups is of the form , , $[a_{z}, a_{z+1}, \ldots, a_{n-1}, a_{n}, a_{1}, a_{2}, \ldots, a_{x-1}]$.
If there are multiple correct answers, any of them is allowed to be output.
4
1 2 3 4
1
1 3 4
7
1 6 1 0 5 3 2
0
2 3 6
8
3 1 4 1 5 9 2 6
1
3 6 8
提示
In the third example, the optimal partition looks as follows:
In this case, the sums in the groups are , , and .
Scoring
- ( points): ;
- ( points): for ;
- ( points): there exists a partition where the sought difference is equal to ;
- ( points): ;
- ( points): ;
- ( points): ;
- ( points): ;
- ( points): with no additional restrictions.