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 .
题目大意
题目描述
提示:本题的时间限制是3s,为默认值的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.