RPLC - Coke madness

David likes coke, lets say he likes it a lot... One day he was walking by a narrow street when he sees a lot of bottles of cokes, from different brands, he wants to drink it all, but he noticed that one brand gives him power, the other brand weaken him, now, he can wait and regain more energy, but he don't want to do that, he will wait at the beginning and, when he has the sufficient energy he will drink all the cokes in the street.

Please, help him find when he will be in the perfect moment to drink all the cokes.


Will start with an integer T denoting the number of test cases, then, T lines will follow, for each test case, there will be an integer N, then, in the next line will be N integers, this will be the number of cokes, and the values of the cokes in the floor (the positive one gives energy, the negative ones will take his energy).


Each test case will output the string “Scenario #i: “ where i is the number of test case analyzed, followed by the minimum energy required by David to pass the street.


4 -10 4 4 4
1 2 3 4 5

Scenario #1: 7
Scenario #2: 1

“The life of David should never reach 0 or less”


1 <= N <= 1000000
-10000000 <= Ni <= 10000000

hide comments
sanket17: 2019-08-20 13:02:03

take care of the output format

aj_254: 2019-05-17 19:16:47

easy one

pranjulpal18: 2018-11-09 10:21:32

I forgot the condition that health should also not reach '0'.Costed me 5 WA :(

ayusofayush: 2018-10-07 22:50:22

take tc:
-10 -10 76 -144
above tc shall be helpful
thanks @sriraj

dynamo214: 2018-08-21 16:07:42

more tc:
4 -3 4 -5 4 -10
ans-> 7

ashish_k1998: 2018-08-12 18:46:16

logical but easy one!!!!

AC in one go...!!

a161112225: 2018-08-10 23:06:50

easy one !!!!!
my 100th.....

wrzoboo: 2018-06-05 16:35:09

Luckily test cases are not as harsh as I expected (they don't quite reach what's described here) so I got AC in one with Python3

amitboss: 2017-12-29 20:46:38

use long long int , bcoz int caused me 1 wa!

ayushagg31: 2017-06-10 07:14:35

same as :http://www.spoj.com/problems/SABBIRGAME/

Added by:david_8k
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own Problem used for the RPL contest