Codeforces Round 1124 (Div. 1, Div. 2) Editorial ### ⭐ **Hope you enjoyed the problems!** ⭐
<span style="font-size: 20px;">[problem:2269A]</span><br>
**Idea:** [user:Hamed_Ghaffari,2026-09-26]<br>
**Preparation:** [user:Hamed_Ghaffari,2026-09-26]
<spoiler summary="Hints">
<spoiler summary="Hint 1">
If Hamed waits $d$ days before withdrawing, the amount of money in his card increases by exactly $2^d$.
</spoiler>
<spoiler summary="Hint 2">
For fixed $a+b$, is $2^a+2^b$ larger when $a,b$ are close together, or when one is as large as possible?
</spoiler>
</spoiler>
<spoiler summary="Solution">
If Hamed waits $d$ days before withdrawing, the amount of money in his card increases by exactly $2^d$.
Therefore the problem becomes:
Split $n$ into exactly $k$ positive integers $a_1,\dots,a_k$, and maximize $$2^{a_1}+2^{a_2}+...+2^{a_k}$$
For fixed $a+b$, $2^a+2^b$ is larger when one of them is as large as possible.
<spoiler summary="Proof">
Suppose two segment lengths are $a\le b$, with $a>1$. Move one day...
. Since the frequency array stores counts rather than only presence, equal
prefix XOR values at, > The frequency array contains $s_L,s_{L+1},\ldots,s_R$., Keep the larger side in the frequency array, iterate over the smaller side, and
search for the, Therefore, after fixing one endpoint, we only need a frequency array to
determine whether the, frequency array, and then process the larger child., frequency array. 3. Iterate over the endpoints belonging to the smaller side.
4. For every value $s_x
Full text and comments »