Please help me to identify that where is my code going wrong…
https://www.codechef.com/viewsolution/24249257
i have just some parts of your code ( only 2 lines) and got a AC
link : CodeChef: Practical coding for everyone
added these two lines:
1.for fast IO
ios_base::sync_with_stdio(false);
cin.tie(NULL);
2. you used q as long long int array of a large size i used vector instead of array so that i can save space.
Why I am getting TLE if I can’t use vector in place of array?
its interesting , there is no problem with using an array the problem lies using the following statement
int q[100000]={ }; or int q[100000]={0};
replace the statement with int q[100000];
you will get an AC.
I think that the array is set to a given value so it consumes time and results in a TLE , though I am not sure about this.
Sorry, i was wrong. I tried to change your code. Moving the initialization of the variables and some conditions, and I got AC. CodeChef: Practical coding for everyone
Ok, I found the cause of the problem with some tests.
https://www.codechef.com/viewsolution/24268129
https://www.codechef.com/viewsolution/24268139
The real problem is the inizialization of long long int q[100000] = {}; only by moving this line of code out of the while loop, we get AC.
@yashshahiiitdm