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:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.