Very easy

Execution time limit is 3 seconds

Runtime memory usage limit is 128 megabytes

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed away. The only constraint stopping you from robbing each of them is that adjacent houses have a security system connected, and it will automatically contact the police if two adjacent houses are broken into on the same night.

Given a list of non-negative integers representing the amount of money in each house, determine the maximum amount of money you can rob tonight without alerting the police.

The first number contains the number of houses $n(1≤n≤10_{6})$. The second line contains $n$ non-negative integers $a_{1},a_{2},...,a_{n}$, where $a_{i}$ is the amount of money that can be taken from the $i$-th house.

Print the maximum sum you can steal tonight without triggering a police alert.

Input #1

Answer #1