Hi
I'm having a exercise which started with "Time Limit: 1000MS Memory Limit: 65536K" what does that mean??
and how can we calculate memory and time ???
thanks in advance
Hi
I'm having a exercise which started with "Time Limit: 1000MS Memory Limit: 65536K" what does that mean??
and how can we calculate memory and time ???
thanks in advance
proud to be from aui www.aui.ma and also a great elton john's fan
That CAN be difficult.
You need to understand what you are about to store in memory (including or excluding of code, depending on the definition) - It's pretty easy to write a piece of code to do sizeof() on some types to get a starting point for the basic data types [or you can just calculate it by hand by looking at the data type and using the individual sizes of variables, e.g. 4 bytes for a int, 4 bytes for a pointer, 2 bytes for a short, etc, etc]
By the way, on average, a line of code is approximately 10-12 bytes - but this DOES depend on the compiler, the architecture of the processor, and how complex you make your lines.
Execution time is fairly trivial on small simple processors, but modern processors are much more complicated, as cache hit rate and memory latency makes a big impact on the data (instruction) throughput.
Also, in most environments, there are tools to analyze the executable file for the size of the code and data contents - the tools vary from one system to another.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
you can use gethrtime() to time how long your program takes. Not sure about the memory though, it probably means the amount of memory that you allocate for your variables...
QuantumPete
"No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
"Have you tried turning it off and on again?" - The IT Crowd
>what does that mean??
It probably means that your program has to run within the time and space constraints. In other words, when you run it, it can't take longer than 1000ms and can't use more than 65536K of memory.
>and how can we calculate memory and time ???
A profiler can give you this kind of information.
My best code is written with the delete key.