11462 - Age Sort
Moderator: Board moderators
-
- New poster
- Posts: 18
- Joined: Sun Jul 20, 2008 7:05 pm
11462 - Age Sort
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.
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
Hello!
Perhaps may help to you this sentence:
Perhaps may help to you this sentence:
You know that no individual in that country lives for 100 or more years.
Sorry for my poor english
-
- Experienced poster
- Posts: 196
- Joined: Wed May 02, 2007 10:12 pm
- Location: Hungary, Pest county, Halasztelek
- Contact:
Re: 11462 - Ages Sort
And fast input/output.SeregiB wrote: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
Hey Robert, you have lots of 0.000 solved problems. What's the fast input/output that you use?
Runtime errors in Pascal are reported as Wrong Answers by the online judge. Be careful.
Are you dreaming right now?
http://www.dreamviews.com
Are you dreaming right now?
http://www.dreamviews.com
-
- Experienced poster
- Posts: 196
- Joined: Wed May 02, 2007 10:12 pm
- Location: Hungary, Pest county, Halasztelek
- Contact:
Re: 11462 - Ages Sort
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) ?
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) ?
-
- Experienced poster
- Posts: 196
- Joined: Wed May 02, 2007 10:12 pm
- Location: Hungary, Pest county, Halasztelek
- Contact:
Re: 11462 - Ages Sort
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).
And I print the output by fwrite if the length>8000 bytes (or we have finished the program).
-
- New poster
- Posts: 18
- Joined: Sun Jul 20, 2008 7:05 pm
Re: 11462 - Ages Sort
Ok. Now it runs in 1.5s
Thanks anyway.
Thanks anyway.
Last edited by JohnTortugo on Thu Apr 30, 2009 4:26 am, edited 1 time in total.
Re: 11462 - Ages Sort WA
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
Last edited by nahid on Fri Aug 22, 2008 8:20 pm, edited 1 time in total.
-
- A great helper
- Posts: 383
- Joined: Mon Oct 18, 2004 8:25 am
- Location: Bangladesh
- Contact:
Re: 11462 - Ages Sort
And last integer of the sorted list should not be followed by a trailing space.
Re: 11462 - Ages Sort
Thaks to Hellone and emotional. I got AC
-
- New poster
- Posts: 3
- Joined: Wed Aug 29, 2007 4:05 am
- Contact:
Re: 11462 - Ages Sort
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,
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,
(
-
- Learning poster
- Posts: 97
- Joined: Fri Aug 22, 2008 10:18 pm
- Location: CSE.SUST.SYLHET
Re: 11462 - Ages Sort
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
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.
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.