You've got my money and no friends. You know the price P[i] of the piece of candy that would make each of your 1in friends happy. You want to give out the m dollars in a way that makes as many of your friends happy as possible. Make a greedy programme that takes O(n log n) time to figure out how much money you will give each friend.

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter21: Simulation
Section21.5: Simulations With Continuous Random Variables
Problem 7P
icon
Related questions
Question

 You've got my money and no friends. You know the price P[i] of the piece of candy that would make each of your 1in friends happy. You want to give out the m dollars in a way that makes as many of your friends happy as possible. Make a greedy programme that takes O(n log n) time to figure out how much money you will give each friend.

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole