Editorial for Trạm phát sóng
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.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Tiến hành Tìm kiếm nhị phân (Binary Search) cho đáp án bài toán. Với mỗi khoảng cách , cần kiểm tra mỗi thành phố phải được bao phủ bởi ít nhất một trạm phát sóng.
Tiến hành sắp xếp tọa độ các trạm phát sóng. Để kiểm tra khoảng cách là thỏa mãn, mỗi thành phố
được phủ sóng nếu có ít nhất một trạm phát sóng trong khoảng tọa độ
(có thể xử lý bằng Tìm kiếm nhị phân).
Độ phức tạp: với
.
Comments