November Lunchtime Editorials

For SMRSTR, you could use a language which supports large integer values (python or Java).

@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.

In the solution of the 4th question, I do not understand, how he has defined the dp states.

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

Did you read @mgch 's answer?

can anyone please explain the second observation in the @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

@skpro19 if you get the logic then please explain it. it will be a great help :slight_smile: