목록문제 (388)
sm 기술 블로그

import java.util.*; import java.io.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int[] num = new int[N]; int[] numReverse = new int[N]; int[] numDpIncrease = new int[N]; int[] numDpDecrease = new int[N]; int[] result = new int[N]; String[] tmp = br.read..

import sys input = sys.stdin.readline N = int(input()) num = list(map(int,input().split())) numReverse = num[::-1] numDpIncrease = [1]*N numDpDecrease = [1]*N for i in range(N): for j in range(i): if num[i] > num[j]: numDpIncrease[i] = max(numDpIncrease[i], numDpIncrease[j]+1) if numReverse[i] > numReverse[j]: numDpDecrease[i] = max(numDpDecrease[i],numDpDecrease[j]+1) result = [0]*N for i in ra..
import java.util.*; import java.io.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] arr = new int[n]; int[] arrDp = new int[n]; String[] tmp = br.readLine().split(" "); for (int i = 0; i < n; i++) { arr[i] = Integer.parseInt(tmp[i]); arrDp[i] = 1; } ..
import sys input = sys.stdin.readline N = int(input()) arr = list(map(int,input().split())) arrDp = [1 for i in range(N)] for i in range(N): for j in range(i): if arr[i] > arr[j]: arrDp[i] = max(arrDp[i], arrDp[j]+1) print(max(arrDp)) 문제요약 증가하는 수열이 가장 긴 부분은? 설명 코드는 크게 어렵지 않을 것이다. 7 1 4 5 2 3 4 5 로 보자. 값을 하나하나 다 비교해서 수열이 가장 긴 부분에 대해서 가져가면 된다. 먼저 각 인덱스는 1의 수열을 가질 수 있어 1로 초기화 해주었다. for i in range(N..