A crore == 10M, right? lahk == 10K as I recall... :-)
An array of 200M elements (assuming array of pointers pointers) on a 64-bit machine will take 200Mx8 bytes (minimum) of memory, which is 1.6GB. Most systems won't allow you to allocate such sizes on the stack, so you may need to allocate it on the heap with calloc/malloc calls. On some systems, you can allow users to allocate huge stacks, but it really isn't a good idea.
So, can you provide some indication of what you are trying to accomplish? We may be able to provide more relevant advice in how to manage that much memory if we knew.
Hi, now the runtime error is resolved.
Now i have different quesion, the below given code takes around .665 seconds to execute. I want to reduce the time to .3 sec.
Please tell me how to optimise.
and one more thing I haven't used calloc() to save time, junk values would work for me.
Thanks for the reply deceptikon.
I already commented printf(), lets use calloc() instead of malloc(). But the thing is program takes .685 seconds to complete and I want to reduce the time to .3 seconds.
Okay, but that's not going to improve matters. If anything it'll make the code slower because on top of allocating memory (that's another extremely expensive operation), calloc() has to initialize it.
But the thing is program takes .685 seconds to complete and I want to reduce the time to .3 seconds.
I assume you're measuring using a profiler? Why have you picked .3 seconds as the end all be all of performance on this seemingly pointless program? What makes you think .6 seconds isn't fast enough? All of this seems very arbitrary to me, so I'm wondering what you're actually trying to accomplish.
You might want to get all of the details for the problem then. Unless he sent you an exact copy paste from the problem, you're getting a paraphrased version that may be leaving out very important information.
I don't fully understand the problem, but it sounds quite interesting. I went to codility.com, but they don't have their problems listed like some of the code challenge sites (Euler, Code Chef, SPOJ, etc.).