• + 0 comments

    Brilliant. One comment - N is bound to 10^7 and M (K in this code) - only to 2*10^5 (for a total of 4*10^5 points, if no duplicates) - more than an order of magnitude less, so a hashmap may be used instead of of an array. This should improve space complexity for exchange of somewhat worse constant factors.