← All problemsSign in

To add or to multiply game

CodeChefRating 2763Open on judge ↗

Chef and his brother Chefu are playing a game with a sequence of N integers. They take alternate turns to play. In each turn, the player should choose two adjacent integers from the sequence, remove them, and put in their place either their sum or their product. So if the sequence is (5,17,2,4,102), then one valid move would be to select 2 and 4, and replace them with their product, which is 8. S

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