Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- 코딩테스트
- COS PRO
- Java
- DP
- binary search
- 문제풀이
- 문자열
- oracle
- 백준
- 코테
- SWEA
- BOJ
- 건강
- 알고리즘
- 자바
- BFS
- 러닝일지
- dfs
- math
- 이분탐색
- 프로그래머스
- greedy
- MySQL
- SQL
- 운동기록
- 시뮬레이션
- 문제해결
- priorityqueue
- 투포인터
- db
Archives
- Today
- Total
슈콩
[SWEA] 최장 증가 부분 수열 본문

[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWBOKg-a6l0DFAWr
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
[소스 코드]
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int T = Integer.parseInt(br.readLine());
for(int tc=1;tc<=T;tc++) {
int n = Integer.parseInt(br.readLine());
int[] arr = new int[n+1];
st = new StringTokenizer(br.readLine());
for(int i=1;i<=n;i++) {
arr[i] = Integer.parseInt(st.nextToken());
}
int[] dp = new int[n+1];
int result = 0;
int maxIdx = 0;
for(int i=1;i<=n;i++) {
maxIdx = 0;
for(int j=0;j<i;j++) {
if(arr[i]>arr[j] && dp[j]>dp[maxIdx]) {
maxIdx = j;
}
}
dp[i] = dp[maxIdx] + 1;
result = Math.max(result, dp[i]);
}
System.out.println("#"+tc+" "+result);
}
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 진용이네 주차타워 (0) | 2025.11.12 |
|---|---|
| [SWEA] 원 안의 점 (0) | 2025.11.12 |
| [SWEA] 8일차 - 암호문3 (0) | 2025.11.12 |
| [SWEA] 새샘이의 7-3-5 게임 (0) | 2025.11.12 |
| [SWEA] 숫자 조각 (0) | 2025.11.12 |