Ashley P.

asked • 04/01/20

Programming question

Till now, there have been no COVID-19 cases identified in the country XYZ. Scientists and researchers there have conducted a research and discovered that, in a street with houses (imagine that the houses are only on one side of the street, the other side is empty), if residents in a house were affected with the novel Coronavirus, there is a high probability for the houses on either side of that house to be diagnosed with Coronavirus as well. This will result in an extremely high possibility for almost all the houses be affected by COVID-19.

Hearing this, the President of the country XYZ has decided to execute(kill) residents in some houses to save more people from that street.

You will be given an input string, containing the number of residents in adjacent houses for a specific street. Your task to find the maximum number of residents that can be saved from getting infected by COVID-19.


Input Format

Input string contains a set of integers seperated by a space



Constraints

Number of houses in a lane

Output Format

Print the maximum number of residents that can be saved from getting infected by COVID-19.

Sample Input 0

3 5 3 4 3 6


Sample Output 0

15


2 Answers By Expert Tutors

By:

Vinayak P. answered • 04/12/20

Tutor
5 (6)

Senior Software Engineer specializing in Java

Patrick B. answered • 04/02/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Ashley P.

Thanks a lot for the explanation.Does this also matches with the constrain 0<= number of houses in a lane <= 1000
Report

04/02/20

Ashley P.

And how do we input the string here?
Report

04/02/20

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.