336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
백준알고리즘
https://www.acmicpc.net/problem/11052
그냥 DP문제 다이나믹프로그래밍이다. 딱히 풀이 공식은 없다.
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int count = Integer.parseInt(scan.nextLine().trim()); int[] inputArray = new int[count + 1]; int[] memoArray = new int[count + 1]; for(int i=1; i<inputArray.length; i++) { inputArray[i] = scan.nextInt(); } memoArray[1] = inputArray[1]; for(int i=1; i < inputArray.length; i++) { for(int j=1; j<=i; j++) { int value = inputArray[j] + memoArray[i - j]; int memoValue = memoArray[i]; memoArray[i] = Math.max(memoArray[i], value); } } System.out.println(memoArray[memoArray.length-1]); } }
'알고리즘 및 자료구조 > 문제' 카테고리의 다른 글
백준알고리즘 10828번 스택 (0) | 2018.05.01 |
---|---|
백준알고리즘 4673번 셀프 넘버 (0) | 2018.05.01 |
백준알고리즘 11726번 2 * N 타일링 (0) | 2018.04.24 |
백준알고리즘 1159번 농구 경기 (0) | 2018.04.24 |
백준알고리즘 1152번 단어의 개수 (0) | 2018.04.24 |