标签:
#include <iostream>
using namespace std;
int n, dp[10001], i, x[10001];
#define max(a,b) a>b?a:b
int main()
{
cin >> n;
for (i = 1; i <= n; i++)
{
cin >> x[i];
}
dp[1] = x[1];
for (i = 2; i <= n; i++)
{
dp[i] = max(dp[i - 1], dp[i - 2] + x[i]);
}
cout << dp[n] <<"\r\n";
return 0;
}
标签:
原文地址:http://www.cnblogs.com/FENGXUUEILIN/p/4947829.html