..     ..    https://www.acmicpc.net/problem/2579


이건데 계단 오르는거거든 


어디가 잘못된걸까 하...


import java.util.Scanner;



public class Main{


public static void main(String[] args) {


Scanner input = new Scanner(System.in);

int testCase = input.nextInt();


int arr[] = new int[testCase + 1];

int D[] = new int[arr.length];

int P[] = new int[arr.length];


for (int i = 1; i < arr.length; i++) {


arr[i] = input.nextInt();


}

D[0] = 0;

P[0] = 0;

D[1] = arr[testCase];

P[1] = 1;

int size = testCase + 1;


for (int i = 2; i <= testCase; i++) {


if (P[i - 1] == 1) {

D[i] = Math.max(D[i - 1], D[i - 2]) + arr[size - i];

if (D[i - 1] > D[i - 2]) {

P[i] = 0;

} else {

P[i] = 1;

}


} else {

D[i] = D[i - 2] + arr[size - i];

P[i] = 1;


}

}


System.out.println(D[testCase]);


}


}