View Code
1 #include<iostream>
2 #include<cstdio>
3 #include<memory.h>
4 using namespace std;
5 int a[100001],b[100001];
6
7 int main()
8 {
9 // freopen("in.txt","r",stdin);
10 int n;
11 memset(a,0,sizeof(a));
12 memset(b,0,sizeof(b));
13 while(scanf("%d",&n)!=EOF)
14 {
15 int i,j;
16 scanf("%d",&a[0]);
17 b[0] = a[0];
18 for(i = 1,j = 1; i < n; ++i)
19 {
20 scanf("%d",&a[i]);
21 if(a[i] > b[j-1])
22 b[j++] = a[i];
23 else
24 {
25 for(int k = 0; k < j; ++k)
26 if(a[i] < b[k])
27 {
28 b[k] = a[i];
29 break;
30 }
31 }
32 }
33 printf("%d\n",j);
34 }
35 return 0;
36 }
37
38
39 #include<cstdio>
40 #include<algorithm>
41 using namespace std;
42 int num[100001];
43
44 int main()
45 {
46 // freopen("in.txt","r",stdin);
47 int n,top;
48 while(scanf("%d",&n)!=EOF)
49 {
50 scanf("%d",&num[0]);
51 top = 1;
52 for(int i = 1; i != n; ++i)
53 {
54 scanf("%d",&num[i]);
55 int *p = lower_bound(num,num+top,num[i]);
56 if(p-num == top) ++top;
57 *p = num[i];
58 }
59 printf("%d\n",top);
60 }
61 return 0;
62 }
2 #include<cstdio>
3 #include<memory.h>
4 using namespace std;
5 int a[100001],b[100001];
6
7 int main()
8 {
9 // freopen("in.txt","r",stdin);
10 int n;
11 memset(a,0,sizeof(a));
12 memset(b,0,sizeof(b));
13 while(scanf("%d",&n)!=EOF)
14 {
15 int i,j;
16 scanf("%d",&a[0]);
17 b[0] = a[0];
18 for(i = 1,j = 1; i < n; ++i)
19 {
20 scanf("%d",&a[i]);
21 if(a[i] > b[j-1])
22 b[j++] = a[i];
23 else
24 {
25 for(int k = 0; k < j; ++k)
26 if(a[i] < b[k])
27 {
28 b[k] = a[i];
29 break;
30 }
31 }
32 }
33 printf("%d\n",j);
34 }
35 return 0;
36 }
37
38
39 #include<cstdio>
40 #include<algorithm>
41 using namespace std;
42 int num[100001];
43
44 int main()
45 {
46 // freopen("in.txt","r",stdin);
47 int n,top;
48 while(scanf("%d",&n)!=EOF)
49 {
50 scanf("%d",&num[0]);
51 top = 1;
52 for(int i = 1; i != n; ++i)
53 {
54 scanf("%d",&num[i]);
55 int *p = lower_bound(num,num+top,num[i]);
56 if(p-num == top) ++top;
57 *p = num[i];
58 }
59 printf("%d\n",top);
60 }
61 return 0;
62 }