#include #include using namespace std; class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x v(n); for(int i : range(n)) { scanf("%d", &v[i]); } if(n == 1) { printf("%d\n", v[0]); return 0; } vector dp(n); dp[0] = v[0]; dp[1] = max(v[0], v[1]); for(int i : range(2, n)) { dp[i] = max(dp[i-1], dp[i-2] + v[i]); } printf("%d\n", dp[n-1]); return 0; }