Maximum Increment sub-sequence
The inspiration for this to me is:
1, the longest increment subsequence is actually the dynamic scale type without knowing the starting point.
2, the use of dynamic rules on the ordered data (if the rectangle is not sorted, there is no "previous rectangle cannot contain the assertion of the back rectangle" = = "before the number is less than the number of subsequent")
Procedure: Sort + Maximum increment subsequence
Motion regulation equation: F[i]=max (f[j]+1) (1<=j<i, a[j]<a[i]&&b[j]<b[i]) = = The equation of dynamic regulation for the longest increment sub-sequence
1#include <stdio.h>2 inta[1001], b[1001], f[1001];3 voidQsortintLintR)4 {5 intx, Y, mid1, Mid2, temp;6mid1=a[(L+R)/2];7mid2=b[(L+R)/2];8x=l;9y=R;Ten while(x<=y) One { A while(a[x]<mid1| | (A[X]==MID1&&B[X]<MID2)) X + +; - while(a[y]>mid1| | (A[Y]==MID1&&B[Y]>MID2)) y--; - if(x<=y) the { -temp=A[x]; -a[x]=A[y]; -a[y]=temp; +temp=B[x]; -b[x]=B[y]; +b[y]=temp; AX + +; aty--; - } - } - if(l<y) qsort (l, y); - if(x<r) qsort (x, r); - } in intMain () - { to intN, I, K, temp, ans=1; +scanf"%d", &n); - for(i=1; i<=n; i++) the { *scanf"%d%d", &a[i], &b[i]); $ if(a[i]<B[i])Panax Notoginseng { -temp=A[i]; thea[i]=B[i]; +b[i]=temp; A } the } +Qsort1, n); - for(i=1; i<=n; i++) $ { $ for(k=1; k<i; k++) - { - if(a[i]>a[k]&&b[i]>b[k]&&f[k]+1>F[i]) the { -f[i]=f[k]+1;Wuyi } the } - if(F[i]>ans) ans=F[i]; Wu } -printf"%d", ans+1); About return 0; $}Full Code
Report on solving problems of rectangle rectangular Sleeve