CHEFPSA Video Solution

Here it is: CHEFPSA Solution - CodeChef January Long Challenge 2020 - YouTube
Commented code: CodeChef: Practical coding for everyone
Comments, questions, requests, criticism, are all welcome!

20 Likes

ThankYou. I appreciate your effort of putting video solutions just after finishing of contest

4 Likes

Can someone help me find problem in this code
https://www.codechef.com/viewsolution/28973270

Just a question , are you checking presence of x-a[i] in array.

It will be there i think cause without it sum % (n+1) would not be 0

Have you tried:
n=3, sum=4
1, 1, 2, 0, 0, 0

Please do video solution for ARMYOFME as well. :sweat_smile:

yep tried ans coming out to be 0 as expected

@tmwilliamlin Iā€™ve done exactly what youā€™ve mentioned.
(I agree with the TLE because Iā€™m calculating factorials in a very slow way.)

But, can anyone help me point out why WA in some test cases, while AC in some.

https://www.codechef.com/viewsolution/28971136#

First of all reason to TLE, You are taking long input array using input() take inputs using readline()
Secondā€¦ I think in your solution you have assumed that all inputs are valid prefix suffix sum array.

Look at my Submission (with Detailed Analysis and Explanation)
Solution

Thanks @balrams
My code seems to fail here:

I was considering a pair to valid when its sum is equal to max element. (:disappointed:

Yes, exactly bcz its not neccesary that array sum is maximum always. there can be negative values in your original array which can make sum to less. So, better to check for sum is to find pairs such that multiplication with (n+1) gives the sum of whole input sum.
And It can be proved. during contest, I verified this for almost all type of inputs.

kindly have a look. I donā€™t know where it went wrong for some test cases.(CodeChef: Practical coding for everyone)

Can someone please have a look. Same logic code was running well in Python(Giving TLE in 6th Subtask) but showing wrong answer in C++(In 4 Subtasks)
(CodeChef: Practical coding for everyone).
Please take a look.

1 Like

My code also fails in those testcases
UPD: Okay I understood my mistake , I am not checking sum(a)%(n+1)==0

Stay tuned, Iā€™m working on it.

2 Likes

I think this test case will cause your solution to fail:

1
4
2 2 0 0 0 0 3 3

Answer should be 0.

Yeah, He is

Same logicā€¦ Everything same but still 1 TLE who stole my 80 pointsšŸ˜…

https://www.codechef.com/viewsolution/28960680
HELP ME OUT WITH THAT TLE

Try changing all ā€˜endlā€™ with ā€œ\nā€ in your code.

2 Likes