CONSESNK - Editorial

Due to sorting my solution is O(nlogn) . However my solution is simpler.

Due to sorting my solution is O(nlogn) . However my solution is simpler.

https://discuss.codechef.com/questions/99473/consesnk-unofficial-editorial
Maybe this is what you are looking for .

https://discuss.codechef.com/questions/99473/consesnk-unofficial-editorial .
Check out my unofficial editorial.

why am I getting TLE? https://www.codechef.com/viewsolution/13898082

@sanyamg123 I still cant figure out how f(x)=∑1≤i≤N|x+(i−1)⋅L−Si| this function is generated. Can you please explain it in detail?

@tommy_trash can you answer me why you have used high-low>=10 in your code

what is wrong in my code https://www.codechef.com/viewsolution/13904747

Do not use the data type as double. Use integer or long long int. And use the formulas for calculating m1 and m2 as : m1=low+(high-low)/3; m2=high-(high-low)/3; This will give you an AC.

@prak_blah this answer on math.stackexchange will help you understand the intuition- https://math.stackexchange.com/a/113336/448897

1 Like
//