Solution (source code)

= Solution

For decreasing probabilities, the first $x$ symbols each have probability at least $P(x)$, so $xP(x)\leq1$. Hence
$$
\boxed{L^*(x)=\lfloor\log_2x\rfloor
\leq\log_2x\leq-\log_2P(x).}
$$