I was not able to solve it , but looking at constraints i thought that we can solve using slope and brute force . Do we need to optimize this approach , if yes how ?

was my first contest btw.

Yeah I think it can be solved using this approach and slightly optimizing it. I tried but the time left was not enough to think all the logic.

1 Like

Did anyones O(n^2) got AC ? Reason being O(n^2) can reach till 10^8 and i thought it might give TLE since we additional operational also in a loop.

Although there is one line, that says the line segment connecting two endpoints should not touch or intersect any other barrier, but I felt that there should have been more clarification about what exactly happens on barriers with same x.

1 Like

can some one share there solution which is less than O(n^2) .