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
How was wifi made? bro
Helen [10]

Answer: "Once a Transmitter receives data from the internet, it converts the data into a radio signal that can be received and read by WIFI-enabled devices. When was WIFI invented? Wifi was invented and first released for consumers in 1997 when a committee called 802.11 was created."

(Non Of This Information Is Mine I Have No Rights Or Ownership Not For Plagiarism Purposes Information Based Only 2022.)

Explanation: ...

3 0
2 years ago
Read 2 more answers
Code is the code or instructions used to create a Web page or<br> program.
Paha777 [63]
Answer:
HTML
Explanation:

5 0
2 years ago
Julian downloaded some of the music he created to play for his friend. Julian's friend wore headphones to listen to the music. A
egoroff_w [7]
B) output device

bc you’re using them to listen to something
6 0
3 years ago
Read 2 more answers
Before you start creating a database, you should first use paper to plan, test, and revise. True False
Licemer1 [7]
<span>Before you start creating a database, you should first use paper to plan, test, and revise. True or False?
TRUE</span>
8 0
3 years ago
Read 2 more answers
You are part of a development team that needs to adopt an integrated development environment tool to increase programmer product
Ber [7]

Answer:

honestly I think the other one is correct

Explanation:

4 0
2 years ago
Other questions:
  • you are a software engineering consultant and have been called in by the vice president of finance of a corporation that manufac
    10·1 answer
  • Which of the following is a good choice to help you stay organized when you are away from the office? A. Personal Information ma
    7·1 answer
  • Write a program that produces this output:
    10·1 answer
  • When you tell an acquaintance your telephone number, you do not recite the digits one by one at a constant rate, as in "3, 3, 7,
    11·1 answer
  • Which of the following works on the pay-per-click (PPC) and cost-per-click (CPC) concept? ~ Plato
    9·1 answer
  • Find the simple interest Jay owes on a five-year student loan of $48,000 with an annual interest rate of 5%.
    6·1 answer
  • Hello can you please help with this if you want to thank you!
    15·2 answers
  • What is 2D thinking and 3D thinking? i literally don't understand
    6·1 answer
  • Full form of http.<br>wrong answer will be reported ​
    6·2 answers
  • Which of the following best describes the impact of Creative Commons?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!