1993: [USACO 2023 February Contest Gold] Problem 1. Equal Sum Subarrays

文件提交:无需freopen 内存限制:256 MB 时间限制:3.000 S
评测方式:普通裁判 命题人:
提交:2 解决:1

题目描述

FJ gave Bessie an array a of length N (2N500,1015ai1015) with all N(N+1)2 contiguous subarray sums distinct. For each index i[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 N.

The next line contains a1,,aN (the elements of a, in order).

输出

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

样例输入

2
2 -3

样例输出

2
3

提示


Decreasing a1 by 2 would result in a1+a2=a2. Similarly, increasing a2 by 3 would result in a1+a2=a1.

SAMPLE INPUT:

3

3 -10 4

SAMPLE OUTPUT:

1

6

1

Increasing a1 or decreasing a3 by 1 would result in a1=a3. Increasing a2 by 6 would result in a1=a1+a2+a3.

SCORING:

  • Input 3: N40
  • Input 4: N80
  • Inputs 5-7: N200
  • Inputs 8-16: No additional constraints.

来源/分类