#include int scoreTable[1000]; int main() { int N; int V[1000]; scanf("%d", &N); int i; for (int i=0; i V[1]) printf("%d\n", V[0]); else printf("%d\n", V[1]); } int s1, s2; s1 = takeSushi(0, 0, N, V); s2 = takeSushi(0, 1, N, V); if (s1 > s2) printf("%d\n", s1); else printf("%d\n", s2); } int takeSushi(int score, int position, int N, int V[]) { if (scoreTable[position] > 0) return score+scoreTable[position]; int score1 = score + V[position]; if (position == N-1 || position == N-2) { return score1; } if (position == N-3) { return score1 + V[N-1]; } int s1, s2; s1 = takeSushi(score1, position+2, N, V); s2 = takeSushi(score1, position+3, N, V); if (s1 > s2) { scoreTable[position] = s1-score; return s1; } else { scoreTable[position] = s2-score; return s2; } }