1 / 8
Jun 2008

I am new in SPOJ. How time is counted??? Is it compiling time or anything else.. Please give some tips to reduce the compilation time.[/b]

No, time is running time; how long it takes your program to finish running with the correct answer on SPOJ's servers.

So time excedding is not the programmer's fault it should be the user's fault. So why the programmer will be hampered by the user.

I'm not sure what you mean by user.. your program is run automatically. If you get TLE it means your algorithm is too slow.

I use C compiler. I am new in SPOJ. so how i recover the time exceeding problem?

Write a program which solves the problem faster.. usually a brute force solution is too slow thus gets TLE. If you need particular help on a problem you can post about it..

3 months later

......
	qsort(N,n,sizeof(int),comp);
	qsort(M,n,sizeof(int),comp);
.....
}

....
    sort(AB.begin(), AB.end());
    sort(CD.begin(), CD.end());
....

Above are two codes for the SUMFOUR problem..my question is that why the first code gets a tle ..while second code runs in time.
The basic structure and program flow is same in both cases.
I posted it in this section as i think its is due to some bad programming practice.
I would also like to add that the first code may give an stack overflow ...so declaration as global will work fine..i have tested that code also ..it also gives a tle.
Thanks

**code was edited after clarification by swarnprakash only significant part was not deleted , Thanks

Try using sort(N,N+n); in your first code instead of qsort(N,n,sizeof(int),comp);
That could be the difference.

Suggested Topics

Topic Category Replies Views Activity
C and C++ 0 35 26d

Want to read more? Browse other topics in C and C++ or view latest topics.