Page 1 of 4

11462 - Age Sort

Posted: Wed Aug 06, 2008 7:19 pm
by JohnTortugo
Hello there.

I solved this problem. But it takes ~ 4sec.... How can someone solve this in 0.080? Some type of linear sorting?

I did it using qsort.

Thanks. John. 8)

Re: 11462 - Ages Sort

Posted: Wed Aug 06, 2008 9:32 pm
by SeregiB
Hello!

Perhaps may help to you this sentence:
You know that no individual in that country lives for 100 or more years.

Re: 11462 - Ages Sort

Posted: Thu Aug 07, 2008 12:54 am
by Robert Gerbicz
SeregiB wrote:Hello!

Perhaps may help to you this sentence:
You know that no individual in that country lives for 100 or more years.
And fast input/output.

Re: 11462 - Ages Sort

Posted: Thu Aug 07, 2008 3:53 am
by andmej
Hey Robert, you have lots of 0.000 solved problems. What's the fast input/output that you use?

Re: 11462 - Ages Sort

Posted: Thu Aug 07, 2008 9:49 am
by Robert Gerbicz
fread/fwrite

Re: 11462 - Ages Sort

Posted: Thu Aug 07, 2008 10:23 am
by baodog
Hi Robert!,

yes, I got 80ms using fread/fwrite, but I had to guess the size of input file.
Do you have a way of finding the size of input file without knowing file name?
Is there a function to get it from the handle (0) ?

Re: 11462 - Ages Sort

Posted: Thu Aug 07, 2008 11:30 am
by Robert Gerbicz
I don't know, at once I only read 8192 bytes of the input by fread.
And I print the output by fwrite if the length>8000 bytes (or we have finished the program).

Re: 11462 - Ages Sort

Posted: Thu Aug 07, 2008 7:11 pm
by JohnTortugo
Ok. Now it runs in 1.5s :oops:

Thanks anyway.

Re: 11462 - Ages Sort WA

Posted: Tue Aug 19, 2008 9:04 pm
by nahid
As usual, I'm having WA with 11462. may be i have problem in presentation. in most of the phe probem I get WA. her is my code, someone pls help me.

Code: Select all

removed after AC

Re: 11462 - Ages Sort

Posted: Wed Aug 20, 2008 6:02 am
by helloneo
You should initialize a[] array.. :-)

Re: 11462 - Ages Sort

Posted: Fri Aug 22, 2008 10:47 am
by emotional blind
And last integer of the sorted list should not be followed by a trailing space.

Re: 11462 - Ages Sort

Posted: Fri Aug 22, 2008 8:19 pm
by nahid
Thaks to Hellone and emotional. I got AC

Re: 11462 - Ages Sort

Posted: Thu Apr 30, 2009 2:30 am
by oliveralderete
Not Sort, Not fast I/O, Not Big memory, No Complications
just think a little bit, it could fly.

I was trying with a sort, but i always got TLE

there are other ways.

AC at 1.4 sec

saludos,

Re: 11462 - Ages Sort

Posted: Mon Jun 01, 2009 9:16 pm
by saiful_sust
Hello oliveralderete

I think u r wrong
Because i solve this problem with sorting
it took 0.462 & position 17
u have to use fast input/output & faster sort

Re: 11462 - Ages Sort

Posted: Wed Jun 17, 2009 7:45 pm
by neilor
Dears, only for couriously, there are here some performances tests that I can relate for this problem:

Método Execution time
bubleSort TLE (> 5 seconds)
Qsort Stl with cin / cout 1.072
Quicksort with scanf / printf 0.786 secs (maybe not so good qsort!?)
Mergesort with scanf / printf 0.656 secs (with a best mergesort)
qsort Stl [ sort(age,age + tam); ] 0.596 secs
Counting Sort (with vector) 0.473 secs (18 º world time)
Counting Sort (without vector) 0.456 secs
Counting Sort with fast input 0.343 seconds (13 º )
Counting Sort with fread/fwrite 0.204 seconds (10 º )
Counting Sort fread/fwrite optimized 0.156 (8º)
Counting Sort fread optimized /fwrite optimized 0.052 (2º) same that 1º mundial place.