Official algorithmic problem description and constraints.
Chef has π magic spells. The π-th spell has a volatility of Vi and a strength of Ai.
When spells i and j (1β€i<jβ€N) are activated together, they merge to form a single spell of strength (π΄πΓππ+ππΓπ΄π).
What's the maximum possible strength of a spell Chef can obtain by activating exactly two of his spells?
Detailed video explanations, mathematical intuition, and clean C++ implementation code.