Peak detection via Constrained Optimal Segmentation (Dynamic Programming algorithm)