#P1729. [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 aa of length N(2N500,1015ai1015)N(2 \le N \le 500,−10^{15} \le a_i \le 10^{15}) with all N(N+1)2\dfrac{N(N+1)}{2} contiguous subarray sums distinct. For each index i[1,N]i \in [1,N], 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 NN.

The next line contains a1,,aNa_1, \cdots ,a_N (the elements of aa, in order).

输出格式

One line for each index i[1,N]i \in [1,N].

样例 #1

样例输入 #1

2
2 -3

样例输出 #1

2
3

样例 #2

样例输入 #2

3
3 -10 4

样例输出 #2

1
6
1

提示

Explanation for Sample 1

Decreasing a1a_1 by 22 would result in a1+a2=a2a_1+a_2=a_2. Similarly, increasing a2a_2 by 33 would result in a1+a2=a1a_1+a_2=a_1.

Explanation for Sample 2

Increasing a1 or decreasing a3a_3 by 11 would result in a1=a3a_1=a_3. Increasing a2a_2 by 66 would result in a1=a1+a2+a3a_1=a_1+a_2+a_3.

SCORING

  • Input 33: N40N \le 40
  • Input 44: N80N \le 80
  • Inputs 575-7: N200N \le 200
  • Inputs 8-16: No additional constraints.