import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int n = scanner.nextInt(); int[] arr = new int[n]; int[] dp = new int[n]; for (int i = 0; i < n; i++) { arr[i] = scanner.nextInt(); dp[i] = 1; //初始化dp[i]为1,最少拦截1枚 } int answer = 0; for (int i = 0; i < dp.length; i++) { for (int j = 0; j < i; j++) { if(arr[j] >= arr[i]) { //可以把i拼到以a[j]为结尾的递减子序列中 dp[i] = Math.max(dp[i], dp[j] + 1); } } answer = Math.max(answer, dp[i]); } System.out.println(answer); } } }