Codeforces Round 1005 (Div. 2) |
---|
Finished |
You have an array $$$a$$$ of length $$$n$$$ consisting of non-zero integers. Initially, you have $$$0$$$ coins, and you will do the following until $$$a$$$ is empty:
Find the maximum number of coins you can have at the end of the process.
$$$^{\text{∗}}$$$Here $$$|a_i|$$$ represents the absolute value of $$$a_i$$$: it equals $$$a_i$$$ when $$$a_i > 0$$$ and $$$-a_i$$$ when $$$a_i < 0$$$.
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases.
The first line of each testcase contains an integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$a$$$.
The second line of each testcase contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$, $$$a_i \ne 0$$$).
The sum of $$$n$$$ across all testcases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output the maximum number of coins you can have at the end of the process.
363 1 4 -1 -5 -96-10 -3 -17 1 19 2011
23 40 1
An example of how to get $$$23$$$ coins in the first testcase is as follows:
An example of how to get $$$40$$$ coins in the second testcase is as follows:
Name |
---|