Editorial for Điểm gần thứ K


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

Biến đổi bài toán: Với hai số nguyên BK, tìm giá trị X nhỏ nhất thỏa mãn có ít nhất K phần tử của dãy A có giá trị nằm trong khoảng [B-X,B+X]. Từ đó, tiến hành sắp xếp mảng A và thực hiện Tìm kiếm nhị phân với mỗi truy vấn.

Độ phức tạp: O(N.log(N) + Q.log(c).log(N)) với c\ge2.10^8.


Comments