bug fixed and accepted by OJ
a new solution
a O(n^3) solution, TLE
add a O(n^2*lgn) solution, accepted