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
MSSQL
Lelu [443]

Answer:

The code is given below

{  

  string cipher = "";  

//Where cipher is an algorithm used.

  for (int y = 0; iy< msg.length(); i++)  

  {  

      

      if(msg[i]!=' ')  

          /* applying encryption formula ( c x + d ) mod m  

          {here x is msg[i] and m is 26} and added 'A' to  

          bring it in range of ascii alphabet[ 65-90 | A-Z ] */

          cipher = cipher +  

                      (char) ((((a * (msg[i]-'A') ) + b) % 26) + 'A');  

      else

          cipher += msg[i];      

  }  

  return cipher;  

}  

8 0
3 years ago
Which of these is not an application software?
fredd [130]
A; control and measurment
6 0
3 years ago
Read 2 more answers
Which of the following STEM discoverers invented an application that uses summarization technology? Fedkiw Hawking D’Aloisio Gat
iren2701 [21]

Answer:

The correct option is;

D'Aloisio

Explanation:

Summly, the summarization application, founded by Nick D'Aloisio, summarizes news articles into shorter form of small number of sentences, using language processing and rocket science from Stanford Research Institute (SRI) scientists to isolate important items in news articles. D'Aloisio was also the youngest ever person to have been given VC funding to aid in the Summly development.

7 0
3 years ago
Imagine you are spending the weekend with your family in a location with ZERO technology- no phones, TV, computers, video, radio
nexus9112 [7]

Answer:

One to one or many to many communication.

Explanation:

Technology has created a platform for online and on-the-go entertainment, conversation, recreation and games etc. But in a location with zero technology, there is a need to reverse back to traditional communication and social interaction.

Besides sleeping and eat, one to one communication with a relative or a group discussion with the family is made. This is like a form of multicast communication. Games and recreational activities would be conducted, like board games, swimming, dancing, singing etc.

8 0
4 years ago
Javascript and java are really just two slightly different names for the same language.
Lunna [17]

Answer:

False

Explanation:

JavaScript is language used along with html documents.

Java is a full-fledged programming language that handles applications.

7 0
2 years ago
Other questions:
  • _ includes websites that encourage interaction and connection among people, businesses, and organizations. A. News sites B. Sear
    5·2 answers
  • Which type of natural hazard is sometimes caused by human activity?
    6·1 answer
  • The hotspot created by MiFi is password protected and can be used to connect Wi-Fi devices located within ____ feet of the MiFi
    9·1 answer
  • Crystal detected a problem in a computer network, due to which she could not send or receive data within the network. She pings
    5·2 answers
  • How to use command prompt​
    14·1 answer
  • Windows XPProfessional and Windows Vista Both have same devicedrivers.<br> True<br> False
    5·1 answer
  • What is a quasi vpn?
    14·1 answer
  • In a _______ format, the date line and the signature block are centered.
    6·1 answer
  • In the forward chaining technique, used by the inference engine component of an expert system, the _____ condition is evaluated
    5·1 answer
  • A common business practice is to include a worksheet named Documentation that contains a description of the workbook, the name o
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!