CF1739B.Array Recovery
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For an array of non-negative integers a of size n , we construct another array d as follows: d1=a1 , di=∣ai−ai−1∣ for 2≤i≤n .
Your task is to restore the array a from a given array d , or to report that there are multiple possible arrays.
输入格式
The first line contains a single integer t ( 1≤t≤100 ) — the number of test cases.
The first line of each test case contains one integer n ( 1≤n≤100 ) — the size of the arrays a and d .
The second line contains n integers d1,d2,…,dn ( 0≤di≤100 ) — the elements of the array d .
It can be shown that there always exists at least one suitable array a under these constraints.
输出格式
For each test case, print the elements of the array a , if there is only one possible array a . Otherwise, print −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] and [2,8,11] .