Pradeep is very Much interested in share investment. but now a days some time due to share market price rise and fall ,so any particular
day he may got profit or may got loss. so he worried on which paricular period he may invest more so that he earn more profit. you
are the only one of friend of pradeep so help him to find the period.
you are given his N days profit and loss, from a,a.... .a[N-1]
find the period(L,R) in which he earned maximum profit and also maximum profit.
Note :If maximum profit is zero or negative then it represent loss and postive value represent profit. if he didn't get any profit the return period 0 0 and total maximum profit as 0. and in case of multiple index the value of L and R is last updated (see explanation).
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
First line of each test case contains a single integer N denoting number of days.
second line contains N integers seperated by space , represent the loss or profit.
for each test case print 3 integers (period L and R and maximum profit )
Subtask1 : 20 points
Subtask 2 : 80 Points
Sample input: 4 5 5 2 -4 5 -2 3 -2 -4 -1 3 1 3 0 4 10 -10 20 30 Sample output 0 3 8 0 0 0 0 2 4 2 3 50
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2|
Fetching successful submissions