Find number of elements in Y [ ] with values greater than x getting upperbound of x with binary search
int idx = Array . BinarySearch ( Y , x ) ; int ans ; if ( idx < 0 ) { idx = Math . Abs ( idx + 1 ) ; ans = Y . Length - idx ; } else { while ( idx < n && Y [ idx ] == x ) { idx ++ ; } ans = Y . Length - idx ; }