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
Which of the following best explains why some people invest their saving in the stock market and others put their saving in bank
Tanya [424]
The answer to this question is B. Some people feel that the stock market is too risky for them.
7 0
4 years ago
Read 2 more answers
The programmer's job can be broken down into five development steps true or false
wariber [46]
True 
1 clarify programing needs
2 design the program
3 code the program 
4 test the program
5 document and maintain
5 0
3 years ago
What are some positive impacts technology has on the environment?​
dsp73

Answer:

<u>technology</u> has enabled us to capture useful heat through devices such as solar panels

Explanation:

<h3 />
7 0
3 years ago
Read 2 more answers
You are working as a Software Programmer for one of the big retail company. You need to implement the program that can store at
Aleks [24]

Answer:

The C++ code is given below with appropriate comments. Random names of customer information are chosen as samples

Explanation:

#include <iostream>

using namespace std;

int main()

{

// Initialize String Arrays for customerName,customerAddress1,city,state,zip for 15 customers

string customerName[15] = {"Liam","Noah","William","James","Logan","Benj","Mason","Elijah","John","Patty","Cheryl","Nick","Brian","Steve","mark"};

string customerAddress1[15] = {"Liam - Address1","Noah - Address2","William - Address3","James - Address4","Logan - Address5","Benjamin - Address6","Mason - Address7","Elijah - Address8","John - Address9","Patty - Address10","Cheryl - Address11","Nick - Address12","Brian - Address13","Steve - Address14","mark - Address15"};

string city[15] = {"Sitka","Juneau","Wrangell","Anchorage","Jacksonville","Anaconda","Oklahoma City","Fort Worth","Dallas","Sitka","Juneau","Wrangell","Anchorage","Jacksonville","Anaconda"};

string state[15] = {"Alaska","Alaska","Alaska","Alaska","Florida","Montana","Montana","Oklahoma","Texas","Arizona","Tennessee","California","Virginia","Indiana","Virginia"};

int zip[15] = {30041,36602,75062,78952,12071,55874,11236,44512,55262,99874,11020,55820,11304,11587,11047};

// Print Zips for the customers

cout <<"Customer Names"<<"\t"<< "Zip Code"<< "\n";

for (int i = 0; i < 15; i++)

cout <<customerName[i]<<"\t\t\t"<< zip[i] << "\n";

}

5 0
3 years ago
Ashley is the record keeper for a bookshop. She gathers and maintains an organized collection of information. What is Ashley usi
maks197457 [2]

The answer is Database.

Reason being is because because the definition of database matches the statement.

- Collection of information that is organized so that it can be easily accessed, managed and updated. 

3 0
3 years ago
Read 2 more answers
Other questions:
  • A foreign country attempting to access government networks in order to disable a national power grid would be an example of: Sel
    7·2 answers
  • Why do the holes at the top of parachutes make it go slower
    12·1 answer
  • How are envelopes and letterheads different
    6·1 answer
  • Explain the differences between kernel applications of the OS and the applications installed by an organization or user.
    6·1 answer
  • Lifelong learning _____. is only important for professionals with advanced degrees can be formal or informal includes formal cla
    12·1 answer
  • Java: Programming Question: Reverse OrderWrite a program that reads ten integers into an array; define another array to save tho
    10·1 answer
  • Use the drop-down menus to complete statements about archiving and backing up data fileArchiving data files manages the size of
    5·2 answers
  • Write a Scientific report modeling a written reasearch paper on big data applications.​
    6·1 answer
  • A ____ risk assessment evaluates threats to and vulnerabilities of the network.
    7·1 answer
  • Microsoft Office PowerPoint 2016 enables you to create robust multimedia _______.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!