Блог пользователя divyam01986

Автор divyam01986, история, 10 лет назад, По-английски

For this problem the solution is acceptable when an Integer[] array is used but not when the same algorithm is used with an int[] array. Why? Problem URL:http://www.codeforces.com/problemset/problem/682/B TLE Solution:http://www.codeforces.com/contest/682/submission/19309219 Accepted Solution: http://www.codeforces.com/contest/682/submission/19309197

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
10 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +8 Проголосовать: не нравится

Because Arrays.sort() with int[] is using QuickSort that is O(N^2) at worst case.

Arrays.sort() with Integer[] is using MergeSort that is O(N*log(N)) at worst case.