← All problemsSign in

Buying Fruits

Problem description. Tom loves fruits and he wants to buy some. There are N different fruits lying in front of him, tagged with their prices, but he has only $K. He wants to maximise the number of fruits he buys with this money.Help him buy as many fruits as possible. Input The first line contains two integers N and K,second line is an empty string, followed by a line containing N space separat

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