SPOJ.com - Problem MAXLN

I have searched this on internet. but everywhere i understood till here

s= −AC^2+AC+ 4r^2

after this they are telling maximum value occurs when
AC=-b/2a. didnt understand how they got this.

can anyone explain the math please ?

Thanks in advance.

Differentiate s w.r.to AC and you will find that s will be maximum when AC=0.5

For r=1 (sample test case)

s= 4*1^2 - 0.5^2 + 0.5 = 4-0.25+0.5 = 4.25

Not sure what’s b and a in your question…

1 Like