Editorial for REPLACESUM


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.

Subtask 1: 50% test có N2000.

  • Có thể sort vector hoặc mảng lại để kiếm k phần tử nhỏ nhất.
  • Độ phức tạp là O(NlogN(NK)).

Subtask 2: 50% test còn lại không ràng buộc gì thêm.

  • Các bạn có thể sử dụng CTDL đặc biệt như multiset hoặc priority queue để giải quyết đơn giản bài toán này.
  • Chỉ mất O(logN) cho mỗi thao tác.

Comments

Please read the guidelines before commenting.


There are no comments at the moment.