Hello guys, for all those who message me here on codeforces, i cant reply since i have reached my daily message quota...
Now to the Hack for todys Div. 3 B. 1095B - Array Stabilization
For those who tried to solve this problem in java and Arrays.sort() and got hacked, you need to know that this method implements a deterministic dual pivot quicksort for primitive types like int. This maybe doesn't sounds bad, but it is! A deterministic quicksort is only on random input data in , but its worst case behaviour is still . Therefore it is possible to find inputs where you will get TLE (like in my hack).
There are however many ways to fix this here i will list some examples:
- use Integer instead of int
- use Arraylist and Collections.sort()
- use shuffle the int before sorting it