FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » 500. Turbo Sort
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: 500. Turbo Sort [message #172607 is a reply to message #172599] Tue, 22 February 2011 04:30 Go to previous messageGo to previous message
Kevin Wells is currently offline  Kevin Wells
Messages: 4
Registered: November 2010
Karma:
Junior Member
In message <a6c84d7c-f2f0-4141-8ad4-73329dba24a6(at)p12g2000vbo(dot)googlegroups(dot)com>
n00m <n00m(at)narod(dot)ru> wrote:

> http://www.spoj.pl/problems/TSORT/
> My php code gets TimeLimitExceeded. Can it be accelerated somehow?
> Just curious. No problem here with C, C++, Pascal etc.
>
> <?php
>
> $a = array_fill(0, 1000001, 0);
>
> fscanf(STDIN, "%d\n", &$n);
>
> for ($i = 0; $i < $n; ++$i) {
> fscanf(STDIN, "%d\n", &$v);
> ++$a[$v];
> }
>
> //sort($a, SORT_NUMERIC);
>
> for ($i = 0; $i < 1000001; ++$i) {
> for ($j = 0; $j < $a[$i]; ++$j) {
> echo $i."\n";
> }
> }
>
> ?>

Shouldn't it be $i++ not ++$i on the for loop?


--
Kev Wells http://riscos.kevsoft.co.uk/
http://kevsoft.co.uk/ http://kevsoft.co.uk/AleQuest/
ICQ 238580561
I will not cease from mental fight,
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to read/to download attachment on an URI?
Next Topic: Proxy to open blocked sites
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 08:58:12 GMT 2024

Total time taken to generate the page: 0.03335 seconds