← ~/問題
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