링크 : https://www.acmicpc.net/problem/2579
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int dp[301];
int s[301];
void dy(int n){
dp[1] = s[1];
dp[2] = s[1] + s[2];
dp[3] = max(s[1] + s[3], s[2] + s[3]);
for(int i = 4; i <= n; i++){
dp[i] = max(dp[i-2] + s[i], dp[i-3] + s[i-1] + s[i]);
}
}
int main(){
int N;
cin >> N;
for(int i = 1; i <= N; i++){
int tmp;
cin >> s[i];
}
dy(N);
cout << dp[N];
return 0;
}