Page 1 of 4

### 11462 - Age Sort

Posted: Wed Aug 06, 2008 7:19 pm
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.

### Re: 11462 - Ages Sort

Posted: Wed Aug 06, 2008 9:32 pm
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
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
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

### Re: 11462 - Ages Sort

Posted: Thu Aug 07, 2008 10:23 am
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
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
Ok. Now it runs in 1.5s

Thanks anyway.

### Re: 11462 - Ages Sort WA

Posted: Tue Aug 19, 2008 9:04 pm
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
You should initialize a[] array..

### Re: 11462 - Ages Sort

Posted: Fri Aug 22, 2008 10:47 am
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
Thaks to Hellone and emotional. I got AC

### Re: 11462 - Ages Sort

Posted: Thu Apr 30, 2009 2:30 am
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
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
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.