import java.util.*; public class Demo21 { /** 请完成下面这个函数,实现题目要求的功能 **/ /** * 当然,你也可以不按照这个模板来作答,完全按照自己的想法来 ^-^ **/ static int pick(int[] peaches) { int result = 0; if(peaches == null || peaches.length == 0){ return result; } int len = peaches.length; List<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>(); for(int i = 0; i < len; i++) list.add(new ArrayList<Integer>()); for(int i = 0; i < len; i++){ ArrayList<Integer> blist = list.get(i); int max = peaches[i]; blist.add(max); for(int j = i + 1; j < len; j++){ if(peaches[j] >= max){ //记录串中最大的数 max = peaches[j]; blist.add(max); } } } for(int i = 0; i < len; i++){ if(list.get(i).size() > result) result = list.get(i).size(); } return result; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int trees = Integer.parseInt(in.nextLine().trim()); int[] peaches = new int[trees]; for (int i = 0; i < peaches.length; i++) { peaches[i] = Integer.parseInt(in.nextLine().trim()); } System.out.println(pick(peaches)); } }