#include<stdio.h>
int main(){
scanf("%d",&Testcase)
while(Testcase--){
int a[100000] = {0};
/* Other statements */
}
}
In the above program, for every Testcase, the program allocates 100000*sizeof(int) bytes of memory. But in codechef the maximum memory that we can use is about 10 MB. So, is there any optimal way to reduce the memory usage?
P.S. I have tried declaring it as a global variable. But the problem with that is, after every test case, the old Testcase values interferes with the new Testcase values.
Also, I have tried reinitializing the entire array with value 0, after every Testcase, using a for loop. But that takes so long, exceeding the time requirement which is 3 seconds.
The problem I'm trying to solve is http://www.codechef.com/MARCH13/problems/FIRESC
Edit: The total allowable memory limit is actually about 10 MB