Merge branch 'master' of https://github.com/thecodingwizard/usaco-guide
This commit is contained in:
commit
c88ffdf39d
1 changed files with 2 additions and 0 deletions
|
@ -119,6 +119,8 @@ static boolean check(long x){
|
|||
}
|
||||
```
|
||||
|
||||
Note that I used the `Arrays.sort()` function, which uses quicksort on primitive data types such as `long`s. This is fine for USACO, but in other contests, such as CodeForces, it may time out on test cases specifically engineered to trigger worst-case O(n^2) behavior in quicksort. In such contests, you should declare the underlying array as an array of objects, for example `Long` instead of `long`. This forces the `Arrays.sort()` function to use mergesort, which is always O(n log n).
|
||||
|
||||
C++:
|
||||
|
||||
```cpp
|
||||
|
|
Reference in a new issue