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

Обсуждение задачи 1452. Pascal против C++

Solution
Послано Carbon 30 янв 2008 03:23
Sorry for my impudence but my AC program has O(N^2*ln(N)) and takes 234 ms with GREAT optimization (and with memory too). Your solutions (by velocity characteristics) has O(N^2) difficulty and O(N) memory.

First, we should watch all differences between elements (O(N^2)) and then find greatest sequence (O(ln(N))). In process of finding such sequence we should know all differences (O(N^2) memory).

Am I mistaken in something? Could you tell me, in what destination I should think to get quick solution.
Re: Solution
Послано Carbon 3 апр 2008 22:00
I have thought up O(N^2) algo! Now time is 0.109 ms. But it eats O(N^2) memory:(
Re: Solution
Послано Alexander Sokolov [MAI-7] 7 апр 2008 22:14


Edited by author 28.07.2016 15:40
Re: Solution
Послано Vit Demidenko 1 ноя 2010 17:21
N*N*logN with 0.156 ms
Re: Solution
Послано aslan7470 1 апр 2013 12:54
I only store N minimal differences, initially a1-a0,a2-a1,...,a(n-1)-a(n-2) (given a0..a(n-1) sorted sequence). Store it in heap (pyramide), get top (minimal) difference and change it from a(j)-a(i) to a(j+1)-a(i) and push down to the heap's bottom.
Re: Solution
Послано ძამაანთ [Tbilisi SU] 12 авг 2013 04:17
My N*N*logN runs in 0.125