Magician In War
There is a magician fighting against $N$ cities. City $i$ has an army with a strength of $A_i$. Let $K$ denote the city where the magician is currently at. Initially, $K = 1$. Every second, the magician can do **exactly one** of the following: - If $K \lt N$, move to the $(K+1)$-th city and hence increase $K$ by $1$; **or** - Choose an index $i \leq K$ and set $A_i$ to $0$, hence destroying th
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start