#include #include #include using namespace std; //これも動的計画法で行けそう? const int INF = 99999999; vector sushi; vector umai(1001, INF); int dp(int index){ if(index < 0) return 0; if(umai[index] != INF){ return umai[index]; } return umai[index] = max(dp(index-1), dp(index-2) + sushi[index]); } int main(){ int n, tmp; cin >> n; for(int i=0; i> tmp; sushi.push_back(tmp); } cout << dp(n) << endl; /* umai[0] = -100; for(int i=0; i=0 ; j--){ if(umai[j] != INF){ if(umai[j] != i-1) umai[j+sushi[i]] = i; } } } //for(int i=1; i<20 ; i++) cout << umai[i] <=0; i--) { if(umai[i] != INF){ cout << i << endl; return 0; } }*/ }