ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1452. Pascal vs. C++

Carbon Solution [5] // Problem 1452. Pascal vs. C++ 30 Jan 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.
Carbon Re: Solution [1] // Problem 1452. Pascal vs. C++ 3 Apr 2008 22:00
I have thought up O(N^2) algo! Now time is 0.109 ms. But it eats O(N^2) memory:(
Alexander Sokolov [MAI-7] Re: Solution // Problem 1452. Pascal vs. C++ 7 Apr 2008 22:14


Edited by author 28.07.2016 15:40
Vit Demidenko Re: Solution // Problem 1452. Pascal vs. C++ 1 Nov 2010 17:21
N*N*logN with 0.156 ms
aslan7470 Re: Solution [1] // Problem 1452. Pascal vs. C++ 1 Apr 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.
ძამაანთ [Tbilisi SU] Re: Solution // Problem 1452. Pascal vs. C++ 12 Aug 2013 04:17
My N*N*logN runs in 0.125