/* * main.cpp * * Created on: 2017/10/06 * Author: sep */ #include #include #include #include #include #include #include #include #include #include using namespace std; inline int main003(); inline int main045(); inline int main3(); inline int main4(); int main() { #ifdef TEST while(1) #endif main045(); return 0; } inline int main045() { int num; int *value; int **c_value; int i; cin >> num; value = new int[num]; c_value = new int*[num]; for (i = 0; i < num; i++) { cin >> value[i]; c_value[i] = new int[2]; } c_value[0][0] = 0; c_value[0][1] = value[0]; c_value[1][0] = value[0]; c_value[1][1] = value[1]; for (i = 2; i < num; i++) { c_value[i][0] = max(c_value[i - 1][1], c_value[i - 2][1]); c_value[i][1] = max(c_value[i - 1][0] + value[i], c_value[i - 2][0] + value[i]); } cout << max(c_value[num - 1][0], c_value[num - 1][1]); return 0; }