← All problemsSign in

Jack and the magical bean bag

Jack loves beans! While taking a stroll in the park, he stumbled upon N Bags with beans. The i'th of these bags contains Ai beans. He picks up a bag, eats all the beans in it and drops it on the ground. But as soon as he drops the bag, the number of beans in the bag increases magically! Say the bag that used to contain X beans (before eating), now contains [X/2] beans! ,where [x] is the greatest

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