2288A - Youmu Konpaku and the Duel This solution involves the use of calculus to find the minimum in $$$O(1)$$$.
We start by recognising that charges must occur before attacks. Let $$$M$$$ be the total amount of moves:
After $$$C$$$ moves to charge, we reach a maximum attack power of $$$1+C$$$ (since we perform $$$+1 +1 +1 + ... C$$$ times). Then, we must make the minimum amount of attacking moves $$$A$$$ such that the total damage $$$ATK_{tot}$$$ is greater than or equal to the yokai's health $$$x$$$. That is:
Since our highest attack power is $$$1+C$$$:
(using Gauss' formula)
Substitute back into our original equation:
(product rule, rearrange)



