← ~/试题
P2004

Count Not Greater

Medium
// 描述
Given a sorted array and a value x, output how many elements are less than or equal to x.
// 输入格式
The first line contains an integer n (1 <= n <= 10^5). The second line contains n integers in non-decreasing order. The third line contains the query value x.
// 输出格式
A single integer: the count of elements <= x.
// 提示
A binary search (upper bound) answers each query in O(log n).
// 样例
输入样例
5
1 3 3 5 8
4
输出样例
3
// 题目信息
难度Medium
通过率70%
时间限制1000 ms
内存限制65536 KB
通过7