ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1613. Для любителей статистики

Why TLE#6????????? Please HELP!!!!!!!
Послано Enigma [UB of TUIT] 5 окт 2011 12:33

Deleted by author 06.10.2011 15:39

Edited by author 06.10.2011 15:40
Re: Why TLE#6????????? Please HELP!!!!!!!
Послано Enigma [UB of TUIT] 5 окт 2011 14:17
My idea:
There are 2 arrays: peoples[] and index[]. First with "quicksort" I sorted peoples[] and use "binary search". Then with AntiQuickSort I changed the array, as it appears before the first sorting and I've got TLE? Why? I don't found my misteke and I hope that you will help me!!
Re: Why TLE#6????????? Please HELP!!!!!!!
Послано Enigma [UB of TUIT] 5 окт 2011 22:41
Anybody tell me your algo!!!!!!!!!!!
Re: Why TLE#6????????? Please HELP!!!!!!!
Послано Ramil Khayruddinov 5 окт 2011 22:58
Let's count the complexity of your algo.
As I see: NlogN(sorting)+NlogN(antiqsort)+logN(to find any occurrence of people) + N/2(to find suitable number that matches a segment)= (2N+1)logN+N/2. It's only for one query. So, in total it will be N((2N+1)logN+N/2).
It's too slow.

Try to sort once and answer for each query using binary search.

Edited by author 05.10.2011 23:01
Re: Why TLE#6????????? Please HELP!!!!!!!
Послано Enigma [UB of TUIT] 6 окт 2011 10:55
Thank you Ramil! You say that I should try to sort once, but how? I have three days could not decide!

Edited by author 06.10.2011 10:56