Editorial for Dãy con liên tục


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: tranvannhan1911

Ta có thể rút ra nhận xét như sau: Với đoạn ~[p, q]~ để các phần tử trong đoạn là một dãy các số liên tiếp thì ~max([p, q]) - min([p, q]) = q - p~.

Các bạn có thể tìm ra hướng giải với gợi ý trên.

Chú ý: vui lòng giải lại bài với gợi ý trên trước khi xem solution này

  • Các bạn có thể sử dụng segment tree để giải quyết bài toán này. Với mỗi node của segment tree các bạn lưu giá trị min, max của đoạn mà node đó đang nắm giữ.


Comments

Please read the guidelines before commenting.


There are no comments at the moment.