Hlo william.

Consider this testcase

n=3

5 3 7 10 5 10

We go on until removing 10 10 and now we are with 3 5 5 7.

Put our algorithm aside. Just think for the possibilities. They are

3 2 5

5 2 3

7 -2 5

5 -2 7

These are the 4 possibile initial arrays and 4 is the answer.

Now can you plzz explain that pairing part again so that it yields these possibilities . Plz.

# CHEFPSA Video Solution

The pairs are (3, 7) and (5, 5).

We can choose either 3 or 7 in the first pair, which gives 2 possibilities.

We can choose (3, 7) or (5, 5) to be the first pair, which gives 2 possibilities.

2*2=4, which is our answer.

so should we always use “\n” instead of endl ,until and unless stated.

I always use “\n” unless I’m dealing with interactive problems.

1 Like

Can someone explain why am i getting TLE for similar approach:

https://www.codechef.com/viewsolution/28987176

You need to change “%d” to “%ld” in some parts as in this submission: https://www.codechef.com/viewsolution/29054142

This fixes the TLE problem, but you still need to add more checks in order to not get WA.