1D dp 2runs(from l&r)