Editorial for Tìm kiếm nhị phân


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: Yunan

Tiến hành sắp xếp mảng a. Với mỗi truy vấn, sử dụng hàm lower_bound để tìm phần tử a_k nhỏ nhất thỏa mãn lớn hơn hoặc bằng x, sau đó kiểm tra giá trị phần tử a_k có bằng x hay không.

Độ phức tạp: O(n.log(n)+q.log(n)).


Comments