Buying Sweets
There are $N$ sweets in the store. The cost of the $i^{th}$ sweet is $A_i$ rupees. Chef is a regular customer, so **after** buying the $i^{th}$ sweet, he gets a **cashback** of $B_i$ rupees. Chef has $R$ rupees. He is fond of all the sweets, so he wants you to calculate the maximum number of sweets he can buy. Note that he can buy the same type of sweet multiple times, as long as he has the money
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