← All problemsSign in

Spell Splice

CodeChefRating 910Open on judge ↗

Chef has $N$ magic spells. The $i$-th spell has a volatility of $V_i$ and a strength of $A_i$. When spells $i$ and $j$ ($1 \leq i \lt j \leq N$) are activated together, they merge to form a single spell of strength $(A_i\times V_j + V_i\times A_j)$. What's the **maximum** possible strength of a spell Chef can obtain by activating exactly two of his spells? ### Input - The first line of input wi

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start