Dean and Sam
Dean Winchester claims that he is very good with numbers and sequences. His jealous brother Sam decided to embarrass him by giving him a problem he can’t solve. Sam asked Dean to solve this : An array of numbers is given and he has to find the minimum sum possible by taking a subarray of the array. Precisely an array A of size N is given and he has to select two indices i and j such that the sum A[i] + A[i+1] + A[i+2] + …. + A[j] is minimum ( i can be equal to j).
- First line of input will contain the array size N.
- Second line will contain N integers seperated by a space.
- Print in one line the minimum sum.
- 1< = N < = 10^6
- -10^9 < = A[i] < 10^9
-4 2 -9 8 15 11
From index 0 to 2 the sum is minimum ( (-4) + 2 + (-9) = -11 ).
|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, rust, SCALA, swift, 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, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions