题解 | #Redraiment的走法#
Redraiment的走法
https://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa
import java.util.*;
import java.io.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String count = br.readLine();
String str = br.readLine();
int[] dp = new int[Integer.valueOf(count)];
int max=0;
for (int i = 0; i < Integer.valueOf(count); i++) {
dp[i]=1;
for (int j = 0; j < i; j++) {
if(Integer.valueOf(str.split(" ")[j]) < Integer.valueOf(str.split(" ")[i])){
dp[i]=Math.max(dp[i],dp[j]+1);
}
}
max=Math.max(dp[i],max);
}
System.out.println(max);
} catch (IOException e) {
e.printStackTrace();
}
}
}
查看19道真题和解析