Marks :10
: 9 | : 0
A traveler is traveling form city of zeta to omega. He starts with $$$X$$$ amount of money. Every day he spends some money and also he may work on some days to earn money. He may find good work some day and end up earning more than what he spends that day. It also may happen that he spends more than what he earns on any day.
You are given an array $$$A$$$ of $$$n$$$ integers which represents his net savings (earning-expense) on $$$n$$$ consecutive days. You need to find out the minimum non-negative value of $$$X$$$, the traveler should begin with to ensure that he always have some money $$$(\gt 0)$$$ at the end of any day.
The first line of input contains an integer $$$t$$$ $$$(1 \le t \le 10^4)$$$ — the number of testcases. The description of $$$t$$$ testcases follows.
The first line of each testcase contains an integer $$$n$$$ $$$(1 \le n \le 10^{5})$$$ — the size of array $$$A$$$.
The second line of each testcase contains $$$n$$$ space separated integers $$$a_1, a_2,... a_n$$$ $$$(-10^9 \le a_i \le 10^9)$$$ — the elements of array $$$A$$$.
For each testcase, print a single integer — the minimum non negative value of $$$X$$$ in a new line.
334 2 -34-5 1 2 354 -6 1 1 -8
0 6 9
In sample testcase 1, if the traveler starts with an amount of 0,
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.