November Lunchtime Editorials

@bazsi700 , when I change the datatype to double, it is passing 1st test case but when I change it to long double it is passing only 2nd test case, why?(isn’t first test case a sub set of 2nd) I just want to know what’s happening behind…

No, Rating are updated only upto November Cook Off.

how could this brute force solution can get 100% AC
https://www.codechef.com/viewsolution/16379351

Okay, @taran_1407 , thanks a lot :slight_smile:

@bazsi700 can you please tell why you have added .01 in (a[l] + a[r])/2.0

@vipin_bhardwaj To avoid double precision issues. The sum of A_L and A_R may be odd, this is why we need double, but double can have precision issues, so you can’t use = sign on doubles.

E.g. if you have this code:
double x = 2;
x = (x*5)/2;

then probably x == 5 expression will be false, because x will be something like 4.999999 or 5.0000001.

That’s why you should always compare doubles with an error, which I chose 0.01.

1 Like

Well this time , both of us missed the contest.

I didn’t miss contest, it went badly for me (my worst till now) :slight_smile:

Wow… please tell me this one also
let a[l] + a[r] = 5 than we will be finding value in array which is closer to 2 or 3, what should we choose.

I used (l+r)/2 for floorkey and (l+r+1)/2 for ceilkey, no messing with double.

1 Like

@bazsi700 ooo that’s an interesting catch. Thank you very much mate! Highly appreciated.

That thing was hard af to debug. I cant believe I missed that. set lowerbound and normal lowerbound. The more you know about STL XD

@vijju123 It took me 2 hours of thinking and googling to find it out. Glad to share it with others, and spare their time :stuck_out_tongue:

@taran_1407 There wasn’t too much messing

@vijju123 - Sorry xD i will try to put more readable code with some documentation before asking for help next time. Thank you for your efforts! and thanks bazsi once more.

@mgch can you please elaborate 2nd observation a little more?

Did you read @mgch 's answer?

@vijju123 which one?

@pk301, how did you solve it?

@vijju123, pleaseeee have a look at the formatting of LRQUER editorial… I tried to use latex feature, but couldn’t…

Help!!

@skpro19 i didn’t able to solve it for 100 but with a dp approach i get 27