思路:找最长递增子序列(即找后一个元素比前一个元素大的这么一个序列(找出比自己小的并且看它在它序列的位置,比它的位置+1),并统计每个元素的递增子序列的长度,最后得出最长递增序列)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int T = in.nextInt();
for (int i = 0; i < T; i++) {
int N = in.nextInt();
int[] a = new int[N];
for (int j = 0; j < N; j++) {
a[j] = in.nextInt();
}
int[] count = new int[N];
for (int k = 0; k < N; k++) {
count[k] = 1;
for (int l = 0; l < k; l++) {
if (a[l] < a[k] && count[l] + 1 > count[k])
count[k] = count[l] + 1;
}
}
int max = 0;
for (int s = 0; s < N; s++) {
if (count[s] > max) {
max = count[s];
}
}
System.out.println(max);
}
}
}