How to solve Problem G from Codeforces Round 513?

Revision en1, by squarepants, 2020-05-25 19:08:36

Problem Link

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.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English squarepants 2020-05-25 19:08:36 254 Initial revision (published)