luogu#P9127. [USACO23FEB] Equal Sum Subarrays G
[USACO23FEB] Equal Sum Subarrays G
题目描述
Note: The time limit for this problem is 3s, 1.5x the default.
FJ gave Bessie an array of length with all contiguous subarray sums distinct. For each index , help Bessie compute the minimum amount it suffices to change ai by so that there are two different contiguous subarrays of a with equal sum.
输入格式
The first line contains .
The next line contains (the elements of , in order).
输出格式
One line for each index .
题目大意
题目描述
注意:本题的时间限制为 3 秒,为默认时间的 1.5 倍。
FJ 给了 Bessie 一个长度为 的数组 (),其中所有 个连续子数组的和都是不同的。对于每个下标 ,帮助 Bessie 计算最小的改变量,使得数组中存在两个不同的连续子数组的和相等。
输入格式
第一行包含一个整数 ,表示数组的长度。
第二行包含 ,即数组 的元素,按顺序给出。
输出格式
对于每个下标 ,输出一行一个整数,表示改变 的最小改变量。
样例 1 的解释
将 减少 ,可以使得 。类似地,将 增加 ,可以使得 。
样例 2 的解释
将 增加 或将 减少 ,可以使得 。将 增加 ,可以使得 。
评分标准
- 测试点 :
- 测试点 :
- 测试点 :
- 测试点 :无额外限制。
2
2 -3
2
3
3
3 -10 4
1
6
1
提示
Explanation for Sample 1
Decreasing by would result in . Similarly, increasing by would result in .
Explanation for Sample 2
Increasing a1 or decreasing by would result in . Increasing by would result in .
SCORING
- Input :
- Input :
- Inputs :
- Inputs 8-16: No additional constraints.