题解 | #不相邻取数#
不相邻取数
http://www.nowcoder.com/practice/a2be806a0e5747a088670f5dc62cfa1e
while True:
try:
a = int(input())
b = list(map(int,input().split()))
dp = [0]*a
for i in range(a):
if i <= 1:
dp[i] = max(b[:i+1])
else:
dp[i] = max(dp[i-2]+b[i],dp[i-1])
print(max(dp))
except:
break