All submissions for this problem are available.
This time your task is simple.Task:
Mehta has to find the longest subarray whose sum is greater than equal to zero in a given array of length N. After he finds out the length of longest subarray, he has to report how many subarrays of such maximum length exist that satisfy the mentioned property. Note:Subarray is defined as an array of contiguous numbers in a particular array. Subarray(A,B) has length (B-A+1) and consists of all numbers from index A to index B.
First Line of the input consists of a single integer N as described above. Next Line consists of N space separated integers.
In a single line, output the maximum length and number of such subarrays having maximum length separated by a single space.In case, there is no such subarray having sum greater than equal to zero, simply print "-1" without quotes.
Input: 4 -1 -2 3 -1 Output: 3 2
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.