Binary Search
auto it = lower_bound ( Ans . begin ( ) , Ans . end ( ) , maximumIndexReached - B ) ; if ( it == Ans . end ( ) ) { break ; } if ( * it == maximumIndexReached - B ) { maximumIndexReached -- ; } else { break ; } } return maximumIndexReached ; }