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 1306. Sequence Median

It's too hard to slove it in pascal
Posted by 鳳の無望 30 Mar 2004 11:13
the easiest way is save the 3/4 of the number.
but it's almost impossible in pascal.
Re: It's too hard to slove it in pascal
Posted by Илья Гофман (Ilya Gofman) 30 Mar 2004 20:15
hm.. there is an O(N) algo for the problem, what else d'you need?
and what means - save the 3/4 of the number? and why is it impossible in pascal?
Re: It's too hard to slove it in pascal
Posted by Alone alone ! 31 Mar 2004 01:53
Perhaps he wanted to save first 3N/4 numbers, sort them & then insert rest numbers into the list. But i think it will get TLE. But how can it be solved in O(n) ?
Re: It's too hard to slove it in pascal
Posted by Zhang Qi 31 Mar 2004 07:38
I used to be puzzled about the memory either, and think it's a bit unfair for pascal. But I suggest the only thing we can do is to use the memory as less as possible. Since you can save 3/4 of the number to solve it, then what about 2/3 or 7/12 and so. The mothed is similar to yours and just do it more times.
Re: It's too hard to slove it in pascal
Posted by 鳳の無望 31 Mar 2004 10:21
It's won't be TLE if you use quick sort.
Re: It's too hard to slove it in pascal
Posted by 鳳の無望 31 Mar 2004 10:23
Someone else said this program can be sloved by saving n/2 numbers,use heap.
Re: It's too hard to slove it in pascal
Posted by Gigzzz(gigz@inbox.ru) 31 Mar 2004 16:47
There is an easy solution win n/2 memory and O(n*log(n)) time. But i don't know how to solve it with QSort or some algorithm with O(n) time without using n memory, please tell me how...
Re: It's too hard to slove it in pascal
Posted by Илья Гофман (Ilya Gofman) 1 Apr 2004 18:52
hmmm the O(N) algo really needs too much memory.. sorry

Edited by author 01.04.2004 18:55
Re: It's too hard to slove it in pascal
Posted by buggzy 2 Apr 2004 11:05
> there is an O(N) algo for the problem, what else d'you need?

I got TLE on O(N) algorithm ;) (input is parsed 32 times to calculate median bit-by-bit). Oh, my marasmatic brain not generated better solution yet...