Question
Silent Museum Guard
A museum has
A silent guard can inspect any set of rooms, but cannot inspect two adjacent rooms because the alarm sensors of neighboring rooms interfere with each other.
Find the maximum total artifact value the guard can inspect.
The hidden idea: for every room, there are only two meaningful states — take it or leave it.
Input
The first line contains an integer KaTeX can only parse string typed expression.
The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression.
Output
Print a single integer — the maximum total value that can be inspected.
Example
Example 1:
Input
Inspect rooms KaTeX can only parse string typed expression for total value KaTeX can only parse string typed expression.
Example 2:
Input
Input
5
2 7 9 3 1Output12ExplanationInspect rooms KaTeX can only parse string typed expression for total value KaTeX can only parse string typed expression.
Example 2:
Input
4
5 1 1 5Output10