Recently has been practicing with the Java writing problem (link), today did not want to find a very simple two-part problem, I started is directly open int[] array call Arrays.sort () to sort, did not think of Tle, originally because the JDK for int[] sort is the use of fast sorting, The relevant call source code in JDK is as follows
1 Public Static void sort (int[] a) {2 null, 0, 0); 3 }
View Code
And the test data just has the anti-fast row of data, so the card.
The solution is also a lot, it is relatively simple to use the wrapper class integer to call ARRAYS.SORT,JDK implementation is based on Timsort, can be seen from the following source code related calls.
1 Public Static void sort (object[] a) {2 if (legacymergesort.userrequested) 3 Legacymergesort (a); 4 Else 5 null, 0, 0); 6 }
View Code
Alternatively, you can use list, and then call Collections.sort ().
Of course, you can shuffle the array, and then call the sort, but in theory there is still a risk.
CF has a blog post can refer to: http://codeforces.com/blog/entry/7108
about using the Arrays.sort () method in Java tle