Dilworth定理通俗地讲就是对于一个偏序集,最少链划分等于最长反链长度。
通俗点就是一个数列最少的不上升(<=)子序列的条数等于该数列最长上升(>)子序列的长度
就是求最长有序子序列
package bag; import java.util.Arrays; import java.util.Scanner; public class hdu1257 { public static void main(String[] args) { // TODO 自动生成的方法存根 Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int n = sc.nextInt(); int[] xx = new int[n]; int[] res = new int[n]; for (int i = 0; i < n; i++) { xx[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { if (xx[i] > xx[j]) { if (res[j]+1 > res[i]) { res[i] = res[j]+1; } } } } Arrays.sort(res); System.out.println(res[n-1]+1); } sc.close(); } }
标签:int,res,xx,最少,sc,new,拦截,hdu1257 From: https://www.cnblogs.com/xiaohuangTX/p/18237997