Question-> http://www.spoj.com/problems/WEIGHT/
My Algo: Traverse through the array and add a[i]*w to the sum,given w=2 if a[i]<0 & wprev=2, else w=wprev+1.
My code: http://ideone.com/L66Onw
Please give hint of errors in my algo/code or if am I missing any corner case(I tried a lot but couldn't get through,please help). Thanks.