getting TLE for subtask-1 and got AC for subtask-2 &3

for the DIVSUBS problem(DIVSUBS) i am getting TLE for subtask-1 (range of input is 1<=n<=15),
but for subtask-2 (range of input is 1<=n<=1000) and subtask-3 (range of input is 1<=n<=10^5) i got AC. how can this happen ?? By solution can be viewed here, what is the bug in my code??

1 Like

Just change

memset(c,0,(1000000)*sizeof(int));

to:

memset(c,0,(n+1)*sizeof(int));

subtask1 will also get accepted. Instead of initializing a little array(<=15) you are initializing a huge array which can take more time for traversing completely.

1 Like

@achaitanyasai yeah i got it, but why not tle for other subtasks for the same memset instead of changing and also it should take more time for execution in other subtasks as n is of order 10^5

I guess it is because when the size of test cases is small , the number of test cases is more and vice versa

Have a look at this link

//