package easy;
import java.io.BufferedInputStream;
import java.util.Scanner;
/**
*
*poj2533
* 注意是递增序列,不是非递减
* @author NC
*/
public class Poj2533 {
public static void main(String[] args) {
Scanner scan = new Scanner(new BufferedInputStream(System.in));
if (scan.hasNext()) {
int n = scan.nextInt();
int[] data = new int[n];
int[] count = new int[n];
for (int i = 0; i < n; i++) {
int a = scan.nextInt();
data[i] = a;
count[i] = 1;
int max = count[i];
int flag = 0;
for (int j = i - 1; j >= 0; j--) {
if (data[i] > data[j]) {
if (count[j] > max) {
max = count[j];
}//之前想错了,应该是当前最长。要全部比较一次
flag = 1;
}
}
if (flag == 1) {
count[i] = max + 1;
}
}
int max = count[0];
for (int i = 1; i < n; i++) {
if (count[i] > max) {
max = count[i];
}
}
System.out.println(max);
}
}
}
poj2533
最新推荐文章于 2021-07-18 14:26:21 发布