Problem 2625 --Binary Search - Lower Bound

2625: Binary Search - Lower Bound

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

Lower Bound 

For a given sequence A={a0,a1,...,an−1} which is sorted by ascending order, find the lower 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.

The input is given in the following format.

 n 

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 position i (i=0,1,...,n) of the lower bound in a line.
4
1 2 2 4
3
2
3
5
1
3
4

1≤n≤100,000 

1≤q≤200,000 

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

0≤ki≤1,000,000,000

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

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$0 $ms] 3ureka 851012 2022-05-03 13:23:55
内存最少[$1180 $KB] 羽苷羽 815439 2022-03-05 21:46:07
第一AC 计爱玲 282933 2018-10-08 07:30:06
第一挑战 计爱玲 282933 2018-10-08 07:30:06

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

竞赛编号 竞赛名称 竞赛时间 访问比赛
1797 2023-2024-2学期<计算机专业竞赛实训> 第1周练习:STL基础和高精度计算【22计算机】 2024-02-26 00:00:00 请登录
1737 2022-2023-2学期<计算机专业竞赛实训> 第3周练习:STL基础:string/高精度计算【21计算机12345】 2023-03-07 07:00:00 请登录
1681 2021-2022-2学期<算法分析与设计> 第2周练习:STL算法:string/高精度计算 2022-02-28 08:00:00 请登录
1245 2018ACM集训:STL容器算法周赛7 2018-11-24 16:00:00 请登录
1205 2018-2019-1学期安徽科技学院程序设计周赛 2018-10-21 17:00:00 请登录