How to find splitting point in [0,1] to maximize sum of sign function?
WLOG, let $a_i &lt; b_i$. Then $(a_1 - x)(b_i - x) \geq 0$ when $x \leq a_i \vee x \geq b_i$.

Keep a list of intervals $I$. For each $a_i , b_i$ add $(0, a_i]$ and $[b_i, 1)$ to the intervals. Now you just find point $x$ such that it lies within the most intervals in $I$.