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; → Ex3 b; → Ex2 np a; → bi → np a; → bi → 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
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; → Ex3 b; → Ex2 np a; → bi → np a; → bi → 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
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question

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; →
bi →
np
a; →
bi →
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
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 4 images

Knowledge Booster
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.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education