execution speed improving..

Write here if you have problems with your C source code

Moderator: Board moderators

Post Reply
User avatar
a.souini
New poster
Posts: 3
Joined: Fri Sep 08, 2006 10:45 am
Location: casablanca , morocco

execution speed improving..

Post by a.souini » Fri Sep 08, 2006 2:06 pm

i would like to know if there is some kind of tips to make a C program run faster , i mean those for solving problems , and is the stats for some problem correct because i see that there is some peaple who got their code to solve the problems in 0:00.000 Cpu time :o .

jan_holmes
Experienced poster
Posts: 136
Joined: Fri Apr 15, 2005 3:47 pm
Location: Singapore
Contact:

Post by jan_holmes » Sun Sep 10, 2006 2:41 am

I think the one influenced the speed of the program is the algorithm you use to solve that. Except you use Java which needs longer run time than others.

Vexorian
Learning poster
Posts: 100
Joined: Sat Aug 26, 2006 5:50 am

Post by Vexorian » Sun Sep 10, 2006 6:13 am

Specially for the judge and in the case of C/C++(no stl) code, the algorithm's complexity is the most important factor about execution time.

You should get some good info about complexity and dynamic programming.

Edit: I got 0:00:00 many times, it is not actually 0:00:00 , what happens is that the judge is not accurate enough for low execution times. It also cannot measure memory either in short times. So, depending on how busy the judge is the same code can have 0:00:00/64 or 0:04:00/345 . You shouldn't care that much about CPU time time anyways, just make sure to beat the 10 seconds limit, in a contest it won't really matter if an algorithm is the fastest but how fast you submitted a correct solution without making mistakes / TLE.

User avatar
a.souini
New poster
Posts: 3
Joined: Fri Sep 08, 2006 10:45 am
Location: casablanca , morocco

Post by a.souini » Sun Sep 10, 2006 12:25 pm

thanks Vexorian and jan_holmes for your answers that clear up things :) , i really taught that 0:00:00 execution time is a real one , and for that matter i just learned that we have to decrease function calls in our C program or to use the '+' operation instead of the '*' operation as much as possible in order to make it faster .

Moheeb
New poster
Posts: 21
Joined: Fri May 05, 2006 9:08 am
Location: Dhaka ,Bangladesh

Post by Moheeb » Wed Sep 13, 2006 8:09 pm

[/quote]
think the one influenced the speed of the program is the algorithm you use to solve that
[quote]

almost true . but there r so many ways to improve effeciency .u have to know ur particular machine architecture. plz look at the programming perls of John bently, one of the most beautiful book i have ever seen. also look at the following link :
http://www.azillionmonkeys.com/qed/optimize.html
:)

jan_holmes
Experienced poster
Posts: 136
Joined: Fri Apr 15, 2005 3:47 pm
Location: Singapore
Contact:

Post by jan_holmes » Wed Sep 13, 2006 8:13 pm

Thx for the addition, Moheeb... :)

Post Reply

Return to “C”