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++

Solution
Posted by Carbon 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.
Re: Solution
Posted by Carbon 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:(
Re: Solution
Posted by Alexander Sokolov [MAI-7] 7 Apr 2008 22:14


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