logo AlgoBeat OnlineJudge
登录 注册

#212602. [UOI 2025] Partitioning into Three

内存限制:256 MiB 时间限制:500 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 , , .

If there are multiple correct answers, any of them is allowed to be output.

样例

样例输入 1

4
1 2 3 4

样例输出 1

1
1 3 4

样例输入 2

7
1 6 1 0 5 3 2

样例输出 2

0
2 3 6

样例输入 3

8
3 1 4 1 5 9 2 6

样例输出 3

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.