ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

positive and negative , help me
Posted by nttjuvwamsncc 31 Jan 2007 21:39
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)
Re: positive and negative , help me
Posted by nttjuvwamsncc 31 Jan 2007 21:41
any idea
there is an algorithms with O(N^2) complexity
Re: positive and negative , help me
Posted by nttjuvwamsncc 2 Feb 2007 09:31
ANY IDEA ???