View the step-by-step solution to:

In this "investment" problem, you are given $T, which is the total amount you can invest on n different products. Product x (x is a number between 0...

In this "investment" problem, you are given $T, which is the total amount you can invest on n different products. Product x (x is a number between 0 and n-1) has a cost, c[x] and a profit p[x]. The goal is to maximize the profit without spending more than $T.


Example: Product A B C D

Cost 24 10 10 7

Profit 24 18 18 10

If T = 24, the best investment is to spend $20 (out of $24) to buy products B and C and make $36 (18+18) in profit. The API of your program looks like this:

def invest(T, Costs, Profits):
 #return a number, which is the best profit you can make.

Top Answer

The answer is... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online