11462 - Age Sort

All about problems in Volume 114. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

JohnTortugo
New poster
Posts: 18
Joined: Sun Jul 20, 2008 7:05 pm

11462 - Age Sort

Post by JohnTortugo » 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. 8)

SeregiB
New poster
Posts: 3
Joined: Wed Aug 06, 2008 9:24 pm
Location: Hungary, Debrecen
Contact:

Re: 11462 - Ages Sort

Post by SeregiB » 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.
Sorry for my poor english :-)

Robert Gerbicz
Experienced poster
Posts: 196
Joined: Wed May 02, 2007 10:12 pm
Location: Hungary, Pest county, Halasztelek
Contact:

Re: 11462 - Ages Sort

Post by Robert Gerbicz » 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.

User avatar
andmej
Experienced poster
Posts: 158
Joined: Sun Feb 04, 2007 7:45 pm
Location: Medellin, Colombia

Re: 11462 - Ages Sort

Post by andmej » 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?
Runtime errors in Pascal are reported as Wrong Answers by the online judge. Be careful.

Are you dreaming right now?
http://www.dreamviews.com

Robert Gerbicz
Experienced poster
Posts: 196
Joined: Wed May 02, 2007 10:12 pm
Location: Hungary, Pest county, Halasztelek
Contact:

Re: 11462 - Ages Sort

Post by Robert Gerbicz » Thu Aug 07, 2008 9:49 am

fread/fwrite

baodog
Experienced poster
Posts: 202
Joined: Wed Jul 04, 2007 6:53 am

Re: 11462 - Ages Sort

Post by baodog » 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) ?

Robert Gerbicz
Experienced poster
Posts: 196
Joined: Wed May 02, 2007 10:12 pm
Location: Hungary, Pest county, Halasztelek
Contact:

Re: 11462 - Ages Sort

Post by Robert Gerbicz » 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).

JohnTortugo
New poster
Posts: 18
Joined: Sun Jul 20, 2008 7:05 pm

Re: 11462 - Ages Sort

Post by JohnTortugo » Thu Aug 07, 2008 7:11 pm

Ok. Now it runs in 1.5s :oops:

Thanks anyway.
Last edited by JohnTortugo on Thu Apr 30, 2009 4:26 am, edited 1 time in total.

User avatar
nahid
New poster
Posts: 18
Joined: Wed Oct 04, 2006 8:59 pm
Location: DHAKA,BANGLADESH
Contact:

Re: 11462 - Ages Sort WA

Post by nahid » 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
Last edited by nahid on Fri Aug 22, 2008 8:20 pm, edited 1 time in total.

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 11462 - Ages Sort

Post by helloneo » Wed Aug 20, 2008 6:02 am

You should initialize a[] array.. :-)

User avatar
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Re: 11462 - Ages Sort

Post by emotional blind » Fri Aug 22, 2008 10:47 am

And last integer of the sorted list should not be followed by a trailing space.

User avatar
nahid
New poster
Posts: 18
Joined: Wed Oct 04, 2006 8:59 pm
Location: DHAKA,BANGLADESH
Contact:

Re: 11462 - Ages Sort

Post by nahid » Fri Aug 22, 2008 8:19 pm

Thaks to Hellone and emotional. I got AC

User avatar
oliveralderete
New poster
Posts: 3
Joined: Wed Aug 29, 2007 4:05 am
Contact:

Re: 11462 - Ages Sort

Post by oliveralderete » 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,
(

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 11462 - Ages Sort

Post by saiful_sust » 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

neilor
New poster
Posts: 10
Joined: Fri Oct 03, 2008 6:00 pm

Re: 11462 - Ages Sort

Post by neilor » 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.

Post Reply

Return to “Volume 114 (11400-11499)”