I wrote an algorithm that had a complexity of O(n^2 lg n), but was not sure whether it will pass or not. The constraint on n is that it is <= 4000, and the time limit is 0.162s. But how can my algo pass with this much complexity? Are the test cases simple or has someone found a better solution ?