cf 274 div2 - D - binary search / implementation