题解 | #Redraiment的走法#
https://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa
简单DP,最长增长子序列
public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; for(int i = 0; i < n; i++){ arr[i] = sc.nextInt(); } int[] val = new int[n]; for(int i = 0; i < n; i ++){ val[i] = 1; for(int j = 0; j < i; j++){ if(arr[i] > arr[j]) val[i] = Math.max(val[j] + 1, val[i]); } } int max = 0; for(int i = 0; i < n; i++) max = Math.max(max,val[i]); System.out.println(max); } }