CF1739B.Array Recovery

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

For an array of non-negative integers aa of size nn , we construct another array dd as follows: d1=a1d_1 = a_1 , di=aiai1d_i = |a_i - a_{i - 1}| for 2in2 \le i \le n .

Your task is to restore the array aa from a given array dd , or to report that there are multiple possible arrays.

输入格式

The first line contains a single integer tt ( 1t1001 \le t \le 100 ) — the number of test cases.

The first line of each test case contains one integer nn ( 1n1001 \le n \le 100 ) — the size of the arrays aa and dd .

The second line contains nn integers d1,d2,,dnd_1, d_2, \dots, d_n ( 0di1000 \le d_i \le 100 ) — the elements of the array dd .

It can be shown that there always exists at least one suitable array aa under these constraints.

输出格式

For each test case, print the elements of the array aa , if there is only one possible array aa . Otherwise, print 1-1 .

输入输出样例

  • 输入#1

    3
    4
    1 0 2 5
    3
    2 6 3
    5
    0 0 0 0 0

    输出#1

    1 1 3 8
    -1
    0 0 0 0 0

说明/提示

In the second example, there are two suitable arrays: [2,8,5][2, 8, 5] and [2,8,11][2, 8, 11] .

首页