|
|
вернуться в форумI'm sure that my algorythm is correct. It's complexity is O (n log n), because I use quicksort, and then 2 linear procedures. Why do I get TimeLimitExceed? Is it possible not to use sorting? > I'm sure that my algorythm is correct. It's complexity is O > (n log n), because I use quicksort, and then 2 linear > procedures. Why do I get TimeLimitExceed? Is it possible > not to use sorting? because complexity of quicksort in worst case is O(n^2) use heapsort or mergesort and ur program 'll get accepted ( or at least not TimeLimitExceeded ) ;) Just use Random-Quick-Sort it'll take a little time to run it. you can use the quick sort in short algorithim Still AC with O(N^2). ::) But sorting i use. do as this #include <algorithm> using namespace std; int a[n]; sort(a,a+n); |
|
|