positive and negative , help me
let a sequence A[i] (1<=i<=n)
where A[i]=1 or A[i]=-1
a sequence B , subsequence of A (maybe not consecutive) are called "VVV" if ...
- it ends with -1
- and for each j (1<=j<=length(B)) we have B[1]+B[2]+..+B[j] > =0
- and B[1]+B[2]+ ... +B[length(B)] = 0
the problem is : give sequence A , output the number of sequence B which is "VVV",
ex :
INP : A = (1,1,1,1,-1,-1,-1,1)
OUT : 3
because B = ...
(1,-1)
(1,1,-1,-1)
(1,1,1,-1,-1,-1)