1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sweet [91]
3 years ago
12

leetcode A tourism company is providing boat tours on a river with n consecutive segments. According to previous experience, the

profit they can make by providing boat tours on segment $i$ is known as $a_i$. Here, $a_i$ could be positive (they earn money), negative (they lose money), or zero. Because of the administration convenience, the local community requires that the tourism company do their boat tour business on a contiguous sequence of the river segments (i.e., if the company chooses segment $i$ as the starting segment and segment $j$ as the ending segment, all the segments in between should also be covered by the tour service, no matter whether the company will earn or lose money). The company's goal is to determine the starting segment and ending segment of boat tours along the river, such that their total profit can be maximized. Design a dynamic programming algorithm to achieve this goal and analyze its runtime.
Computers and Technology
1 answer:
Soloha48 [4]3 years ago
3 0

Answer:

OPT[i] : segment that end in i with largest amount N

OPT[0] = 0

OPT[i] = max{OPT[i-1] + ai, 0}

for i from 1 to n

if (OPT[i] > max) {

max = OPT[i]

max_i = i

}

count = 0

for i from max_i to 1

count +=a[i]

if (count== max) {

start = i ;

break;

}

You might be interested in
To pinpoint an earthquake's location, scientists need information from how many seismometers?
Mazyrski [523]
<span>C. 3
   Due to the different speeds of P and S waves, a single seismometers can determine the distance to an earthquake. So, for a single station, the localization is any point on a circle around the station. With 2 stations, you'll have two circles that intersect at two points. The 3rd station is needed in order to determine which of the 2 points is the actual earthquake.</span>
7 0
3 years ago
Edward scissorhands Of course, Jim is the villain, but who or what is the antagonist in the film? Explain in detail.
Doss [256]
Jim is the main antagonist while Edward is the main protagonist of the movie.
8 0
2 years ago
What is an entity supertype, and why is it used?
marissa [1.9K]

Answer:

Correct answer is option B (The reason for using supertypes is to minimize the number of nulls and to minimize the likelihood of redundant relationships)

Explanation:

Entity supertype

A  entity supertype is a generic entity type which is related with one or more subtypes.

Use of entity supertype:

The reason for using entity supertype is to reduce redundant relationships and it is also used to minimize the number of nulls.

5 0
3 years ago
-----is a picture icon that is a direct link to a file or folder
Assoli18 [71]
No, it isn't because someone could get confused if they think that could lead them to like a profile or contact page. It's best to just have a separate link.
6 0
3 years ago
Read 2 more answers
Each device attached to your computer has a special program called a(n ________ that enables the device and operating system to
koban [17]
The answer is Device Driver
8 0
2 years ago
Other questions:
  • Stefan is finalizing his presentation by adding media files and preparing it for distribution. Stefan knows that saving a presen
    13·1 answer
  • Enterprise application integration (eai) software enables users to model the business processes and interactions that should occ
    8·1 answer
  • You can toggle between different types of references by pressing the ____ key on your keyboard.
    15·1 answer
  • A(n ____ is anything about which data are to be collected and stored.
    8·1 answer
  • write the algorithm, flowchart and BASIC program to calculate the area of the rectangle length 50m and width 30m.​
    8·1 answer
  • Your friend is overspending and in need of a budget. What type of expense should they reduce next month?
    10·2 answers
  • What is the name given a technological program that typically copies itself and moves through a computer system in order to disr
    10·1 answer
  • Literally no one helps answer my questions so this website is pointless.... : /
    11·1 answer
  • Find the equation of a line which has 10 points the following two coordinates: (4, 0) and (3, 4)​
    13·1 answer
  • What could happen if I break copyright law in the future​
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!