little chef and numbers(march challenge )

using namespace std;

int main()
int t,i,j,k,l,n,m,o;
		if(m==0 || m==1)
{	o=n-k-l;

plz find the error

It doesn’t work like this, simply throwing out the code and asking to find the error. You could have simply given the link to your submission, for that matter. You are expected to tell what you tried, and what is your question accordingly.

However the idea was to choose 2 numbers from all numbers, and subtract the combinations that you can get when you choose 2 numbers from all such numbers whose magnitude is 2. So, if gt represents number of numbers greater than 2, and t represents number of numbers equal to 2, then (gt + t) C 2 - t C 2 will be the answer, i.e. e*(e-1)/2 - t*(t-1)/2 where e = gt + t

1 Like

Integer overflow on target (32 bit) architecture.

Agreed, the question is “incomlete” at least…

@groovypalak: is the TLE not WA the problem? Read the forum for fast I/O…

@v_akshay >> reason for downvoting?

That submission gives TLE. Although you are right about overflow.

Attaching the most recent submission of the OP:

I tested your code on most test simple test cases and it worked fine. The mistake in your code is that the value of n can be upto 10^5 so n * (n-1 ) will be around 10^10 which will exceed the range of int data type. I would suggest you replace int by long long and submit.

P.S. Using o as a variable is a heinous crime :smiley: !! It becomes very difficult to differentiate between 0 and o making debugging hard.

Can you retry writing std::ios_base::sync_with_stdio(false) as the first line in main. There are 3 major reasons for time out I have encountered. Incorrect condition in loop (for, while), non-converging condition in some special case of recursion and slow IO. My suggestion would try to handle third case that I suspect.

Also now that you have said this submission gave TLE, replace the cin and cout by printf and scanf statements.

Initially your answer wasn’t complete IMO, Now it is so take an upvote and be happy :slight_smile: