Problem 2626 --Binary Search - Equal Range

2626: Binary Search - Equal Range

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $12$ 正确数量 $11$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 STL

Equal Range 

For a given sequence A={a0,a1,...,an−1} which is sorted by ascending order, print a pair of the lower bound and the upper bound for a specific value k given as a query.

 lower bound: the place pointing to the first element greater than or equal to a specific value, or n if there is no such element. 

upper bound: the place pointing to the first element greater than a specific value, or n if there is no such element.

The input is given in the following format. 

a0 a1,...,an−1 

k1 

k2 

kq 

The number of elements n and each element ai are given in the first line and the second line respectively. 

In the third line, the number of queries q is given and the following q lines, q integers ki are given as queries.

For each query, print the pari of the lower bound l (l=0,1,...,n) and upper bound r (r=0,1,...,n) separated by a space character in a line.
4
1 2 2 4
3
2
3
5
1 3
3 3
4 4

1≤n≤100,000 

 1≤q≤200,000 

0≤a0≤a1≤...≤an−1≤1,000,000,000 

0≤ki≤1,000,000,000

推荐代码 查看2626 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$0 $ms] Qiqy 609017 2020-07-31 08:52:56
内存最少[$2020 $KB] RUBY-WOO 360256 2019-01-15 22:28:30
第一AC 计爱玲 282935 2018-10-08 07:40:52
第一挑战 计爱玲 282935 2018-10-08 07:40:52

赛题来源/所属竞赛 会津大学《C++ Programming II》 C++程序设计(高级)

竞赛编号 竞赛名称 竞赛时间 访问比赛