728x90
※ SW Expert 아카데미의 문제를 무단 복제하는 것을 금지합니다.
728x90
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
StringBuilder sb = new StringBuilder();
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[][] graph = new int[N + 1][N + 1];
Arrays.fill(graph[0], 1);
int result = 0;
for (int i = 1; i <= N; i++) {
graph[i][i] = graph[i - 1][i];
for (int j = i + 1; j <= N; j++) {
if(arr[i] < arr[j]) {
graph[i][j] = Math.max(graph[i - 1][j], graph[i][i] + 1);
result = Math.max(result, graph[i][j]);
}
else {
graph[i][j]= graph[i - 1][j];
}
}
}
sb.append("#" + tc + " " + result + "\n");
}
System.out.println(sb);
}
}
728x90
'Problem Solving > SWEA' 카테고리의 다른 글
[SW Expert Academy, SWEA 5643] [Professional] 키 순서 (java) (0) | 2023.04.04 |
---|---|
[SW Expert Academy, SWEA 1263] [S/W 문제해결 응용] 8일차 - 사람 네트워크2 (java) (0) | 2023.04.03 |
[SW Expert Academy, SWEA 1230] [S/W 문제해결 기본] 8일차 - 암호문3 (java) (0) | 2023.03.25 |
[SW Expert Academy, SWEA 2115] [모의 SW 역량테스트] 벌꿀채취 (java) (0) | 2023.03.11 |
[SW Expert Academy, SWEA 5656] [모의 SW 역량테스트] 벽돌 깨기 (java) (0) | 2023.03.04 |