Assume that there are certain types of investment projects that can increase your money. Let's assume that project i need investment a; to be done. Once the project is established, it returns your initial investment and gives you an additional profit b₁. Each project may be established once. Currently you have an amount of money equal p. Note that you can't establish a project that takes more money than what you currently have. Your task is to find the maximum possible profit out of these projects. Input The first line contains the integers n and p, where n is the number of available projects and p is your initial amount of money. Then two lines follow, each containing n integers describing the arrays a and b [Note: a; the amount of money that you have to invest (spend) to establish the project i. b;: the amount of revenue that you get as an addition to the amount of money already spent to establish the project i. Output For each test case, output a single value that present the maximum profit you can achieve. Example Ex1 np a₁ →→ b; → Ex2 np a; → b; → Ex3 np a; → b; → input 5 $200 $200 $200 $500 $200 $200 $200 $200 $200 $200 $200 3 $150 $200 $400 $150 $90 $1000 $50 5 $80 $1280 $640 $320 $160 $80 $1280 $640 $320 $160 $80 output $1000 $140 $2480

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter11: Nonlinear Programming
Section11.13: Pareto Optimality And Tradeoff Curves
Problem 5P
icon
Related questions
Question

can you solve this on python please ? 

 

 

a) Design a brute-force algorithm to solve this problem and analyse the complexity of your solution

b) Design a more efficient algorithm to do the same task with less complexity and analyse the complexity of your solution. [Important instruction to be followed: Create an arbitrary input of at least 5 projects and use it to provide full explanation of how your proposed algorithm should work step by step] 

c) Develop a python code to implement your efficient algorithm.

and can you please compare between the algorithms 

Assume that there are certain types of investment projects that can increase your money.
Let's assume that project i need investment a, to be done. Once the project is established,
it returns your initial investment and gives you an additional profit b₁. Each project may be
established once. Currently you have an amount of money equal p. Note that you can't
establish a project that takes more money than what you currently have. Your task is to
find the maximum possible profit out of these projects.
Input
The first line contains the integers n and p, where n is the number of available projects
and p is your initial amount of money.
Then two lines follow, each containing n integers describing the arrays a and b
[Note:
a: the amount of money that you have to invest (spend) to establish the project i.
b;: the amount of revenue that you get as an addition to the amount of money already
spent to establish the project i.
Output
For each test case, output a single value that present the maximum profit you can
achieve.
Example
Ex1
Ex2
Ex3
np
a; →
b; →
np
a; →
b; →
np
a; →
b; →
input
5 $200
$200 $200 $500 $200 $200
$200 $200 $200 $200 $200
3 $150
$200 $400 $150
$90 $1000 $50
5 $80
$1280 $640 $320 $160 $80
$1280 $640 $320 $160 $80
output
$1000
$140
$2480
Explanation
In the first example, your initial amount of money is $200, which enable you to invest in
the first, second, fourth and fifth project that needs only $200 each. By establishing these
four projects apart, the investor will have $200*4 (profit) +$200 (initial basic) = $1000. This
amount of money will enable the establishment the 3rd project that needs $500 of
investment to gain $200 of profit. Finally, to calculate the overall profit, you have collected
$1200, where $200 of them are the initial basic and hence the profit is $1200 - $200 =
$1000.
In the second example, your initial amount of money is $150, which enable you to invest
in the 3rd project only. By doing so, your budget will increases to $200 and hence be able
to invest in the 1st project to again increase your budget to $290. However, this is not
enough to invest in the 3rd project. Finally, you collected $290, where $150 of them are
the initial basic and hence the profit is $290 - $150 = $140.
Transcribed Image Text:Assume that there are certain types of investment projects that can increase your money. Let's assume that project i need investment a, to be done. Once the project is established, it returns your initial investment and gives you an additional profit b₁. Each project may be established once. Currently you have an amount of money equal p. Note that you can't establish a project that takes more money than what you currently have. Your task is to find the maximum possible profit out of these projects. Input The first line contains the integers n and p, where n is the number of available projects and p is your initial amount of money. Then two lines follow, each containing n integers describing the arrays a and b [Note: a: the amount of money that you have to invest (spend) to establish the project i. b;: the amount of revenue that you get as an addition to the amount of money already spent to establish the project i. Output For each test case, output a single value that present the maximum profit you can achieve. Example Ex1 Ex2 Ex3 np a; → b; → np a; → b; → np a; → b; → input 5 $200 $200 $200 $500 $200 $200 $200 $200 $200 $200 $200 3 $150 $200 $400 $150 $90 $1000 $50 5 $80 $1280 $640 $320 $160 $80 $1280 $640 $320 $160 $80 output $1000 $140 $2480 Explanation In the first example, your initial amount of money is $200, which enable you to invest in the first, second, fourth and fifth project that needs only $200 each. By establishing these four projects apart, the investor will have $200*4 (profit) +$200 (initial basic) = $1000. This amount of money will enable the establishment the 3rd project that needs $500 of investment to gain $200 of profit. Finally, to calculate the overall profit, you have collected $1200, where $200 of them are the initial basic and hence the profit is $1200 - $200 = $1000. In the second example, your initial amount of money is $150, which enable you to invest in the 3rd project only. By doing so, your budget will increases to $200 and hence be able to invest in the 1st project to again increase your budget to $290. However, this is not enough to invest in the 3rd project. Finally, you collected $290, where $150 of them are the initial basic and hence the profit is $290 - $150 = $140.
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Project Analysis
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
  • SEE MORE 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