• + 2 comments

    Thanks for the great idea!I wrote a solution with it and solved the problem ( unfortunately after I unlocked the editorial :D ).

    I want to ask you is there any way to compute the final answer in way faster than N^2. Because it is easy to divide the sequence into 2 sets, but the computing of the answer bottlenecks the algorithm.