CHEFPSA Video Solution

Here it is: https://youtu.be/DkJG2GQV0WU
Commented code: https://www.codechef.com/viewsolution/28944179
Comments, questions, requests, criticism, are all welcome!

19 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.(https://www.codechef.com/viewsolution/28971460)

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)
(https://www.codechef.com/viewsolution/28884372).
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