Find number of elements in Y [ ] with values greater than x upper_bound ( ) gets address of first greater element in Y [ 0. . n - 1 ]
int * idx = upper_bound ( Y , Y + n , x ) ; int ans = ( Y + n ) - idx ;