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 »

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 »

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 »

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.
andmej
Experienced poster
Posts: 158
Joined: Sun Feb 04, 2007 7:45 pm
Location: Medellin, Colombia

Re: 11462 - Ages Sort

Post by andmej »

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 »

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

Re: 11462 - Ages Sort

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

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 »

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.
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 »

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 »

You should initialize a[] array.. :-)
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 »

And last integer of the sorted list should not be followed by a trailing space.
nahid
New poster
Posts: 18
Joined: Wed Oct 04, 2006 8:59 pm
Location: DHAKA,BANGLADESH
Contact:

Re: 11462 - Ages Sort

Post by nahid »

Thaks to Hellone and emotional. I got AC
oliveralderete
New poster
Posts: 3
Joined: Wed Aug 29, 2007 4:05 am
Contact:

Re: 11462 - Ages Sort

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

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 »

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)”