๐Ÿšง This website is under construction. ๐Ÿšง
AtCoder
ABC
159
C

ๆ•ดๆ•ฐ
ABC
C

ABC159 C - Maximum Volume

https://atcoder.jp/contests/abc159/tasks/abc159_c (opens in a new tab)

็ธฆใ€ๆจชใ€้ซ˜ใ•ใ‚’ x,y,zx,y,z ใจใ—ใฆใ€ maxโก(xร—yร—z)\max(x\times y\times z) ใ‚’ๆฑ‚ใ‚ใ‚‹ๅ•้กŒใงใ‚ใ‚‹ใ€‚ x+y+z=Lx+y+z=L ใงใ‚ใ‚‹ใ‹ใ‚‰ใ€ maxโก(xร—yร—z)\max(x\times y\times z) =maxโก(xร—yร—(Lโˆ’xโˆ’y))=\max(x\times y\times (L-x-y)) =maxโก(Lxyโˆ’x2yโˆ’xy2)=\max(Lxy-x^2y-xy^2) =โˆ’minโก(x2y+xy2โˆ’Lxy)=-\min(x^2y+xy^2-Lxy) =โˆ’minโก(yร—(x2+(yโˆ’L)ร—x))=-\min(y\times(x^2+(y-L)\times x)) =โˆ’min(yร—{(x+yโˆ’L2)2โˆ’(yโˆ’L2)2})=-min\left(y\times \left\{\left(x+\frac{y-L}{2}\right)^2-\left(\frac{y-L}{2}\right)^2\right\}\right)

ใ‚ˆใ‚Šใ€ yy ใ‚’ๅ›บๅฎšใ—ใŸใจใ x=Lโˆ’y2x=\frac{L-y}{2} ใงๆœ€ๅคงใจใชใ‚Šใ€ๆœ€ๅคงๅ€คใฏ (yโˆ’L2)2ร—y\left(\frac{y-L}{2}\right)^2\times y ใจใชใ‚‹ใ€‚ ใ‚ˆใฃใฆใ€ๅˆถ็ด„ใฎ็ฏ„ๅ›ฒๅ†…ใง yy ใ‚’ๅ…จๆŽข็ดขใ™ใ‚Œใฐใ‚ˆใ„ใ€‚

import numpy as np
 
L = int(input())
 
ans = 0
for y in np.linspace(0, L, 10**6):
    ans = max(ans, ((y - L) / 2) ** 2 * y)
 
print(ans)
 

ๅฎŸใฏ O(1)O(1) ใฎ่งฃๆณ•ใŒๅญ˜ๅœจใ™ใ‚‹ใ€‚

็›ธๅŠ ็›ธไน—ๅนณๅ‡ใ‹ใ‚‰ใ€ abc13โ‰คa+b+c3abc^{\frac{1}{3}}\le \frac{a+b+c}{3} ใ€ๅณใก abcโ‰ค(a+b+c3)3=(L3)3abc\le \left(\frac{a+b+c}{3}\right)^3=\left(\frac{L}{3}\right)^3 ใ‚’่จˆ็ฎ—ใ™ใ‚Œใฐใ‚ˆใ„ใ€‚

print((int(input()) / 3) ** 3)