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!
ThankYou. I appreciate your effort of putting video solutions just after finishing of contest
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
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.
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. (
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.
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.
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.