I couldn't find the link for editorial of that contest. I came up with some $$$\mathcal{O}(n^2)$$$ solution but couldn't improve it any further.
I couldn't find the link for editorial of that contest. I came up with some $$$\mathcal{O}(n^2)$$$ solution but couldn't improve it any further.