2553. Harry Potter Needs Galleons

单点时限: 2.0 sec

内存限制: 256 MB

Harry Potter’s Gringotts account has been seized because he broke into the bank. Ginerva Weasley’s birthday is approaching.Needless to say Harry has to buy a birthday present for her. What does he do now?? He plans to break into the Gringotts again. But having realized now that the goblins are greedy and not trustworthy, he decides to act more intelligently. So with the help of Bill Weasley he compiles all the information about the Gringotts security, every single goblin’s extent of greed and the money in accounts.Harry wants to take with him as many Galleons as possible (ignoring the cheap knuts and sickles). He decides that he will Apparate with Kreacher right at the spot where he will have maximum prospects of getting good money and move ahead and bribe any goblin in his way. And when he has acquired maximum possible number of galleons, he will disapparate with Kreacher.Bill Weasley knows computers too(Not a surprise if you are a son of muggle-object enthusiast Arthur Weasley). He gives harry an array of n integers in which he gives him the amount present in each account and also the bribe that he will have to give to goblins(as negative).Find out the maximum amount that Harry can take with him. Return 0 if Goblins are awfully greedy and cautious.(None of the accounts have any money and goblins are there all the way begging for bribe.)


First Line contains an integer t,is the number of test cases.Each test case will consist of two lines.

The first line will contain a single integer N < 1000 that gives the length of sequence to follow.

This will be followed by a sequence of N integers (each of them less than 1000 ) in a single line.


For every test case, output an integer which denotes the maximum amount that Harry Potter can take with him.


-6 -6 -5 -4 -2 -1
77 -80 22 -9 5 7
22 -55 -66 7 0 6

13 人解决,34 人已尝试。

19 份提交通过,共有 64 份提交。

6.7 EMB 奖励。

创建: 13 年,8 月前.

修改: 5 年,3 月前.

最后提交: 1 年前.

来源: partychen