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
Compare the freedom available to the American media with the freedom available to media in other parts of the world. How does a
Rzqust [24]

in america we are free to say most of whatever we want in media becuase we have free speech here. in other countries, they don't have freedom of speech,and sometimes it also has to do with the political situation. like say in china, where teenagers arent allowed to use the internet for more than a certain amount of time,and arent allowed to talk to each other. thats becuase of the fact that that country is a communist country and the government wants much more control than in other countries.

6 0
2 years ago
It's inventiveness uncertainty and futuristic ideas typically deals with science and technology ......what is it.
marshall27 [118]

Answer:

Necessity is the mother of invention, technology is a tool to aid invention, and science is exploratory means to new ideas and information to approach our future with preparedness.All are necessary and need to be balanced and scrutinised.

Explanation:

5 0
3 years ago
A client is
Vlad1618 [11]

Answer:

a computer that requests a service.

7 0
3 years ago
Read 2 more answers
Modern ssds use a technique called "____" to spread write operations around the storage medium, thus evening out the impact of d
masha68 [24]

The question above has multiple choices as below;

<span>a.      </span>Wear aggregation.

<span>b.      </span>Wear mitigation.

<span>c.      </span>Wear prevention

<span>d.      </span>Wear leveling

The answer is d) Wear leveling.


This technique by some SSD controllers to increase the memory’s lifetime is called wear leveling. The mechanism for this principle is simple: distribute the entries for all the blocks evenly so that they will wear out evenly. Flash controller typically manages wear leveling and uses a wear leveling algorithm to control which physical block to use.







7 0
3 years ago
What can multivariable calculus show for a data set.
dalvyx [7]

Answer:

They can help to explain the relationship between the output and input variables.

Hope this Helps!

5 0
2 years ago
Other questions:
  • ?the single most effective security measure for digital devices is to password protect access to them.
    5·1 answer
  • How many homes can be warmed by one bugatti
    11·2 answers
  • What does ADF means????
    13·2 answers
  • Organisms are classified as producers or consumers acorrding to the way they
    11·2 answers
  • A potential threat to administrators’ ability to manage the correctional system is
    12·1 answer
  • What do you call a collection of pre-programmed commands and functions used in programs?
    10·1 answer
  • Consider the following implementation of a search method:
    13·2 answers
  • Susan discovers the following log entries that occurred within seconds of each other in her Squert (a Sguil web interface) conso
    13·1 answer
  • 1.1 give five (5) reasons why modeling is an important part of system analysis and design
    9·1 answer
  • open your browser and enter the address of this ftp site in the address box: ftp.cengage. if your browser supports ftp, a logon
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!