-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1044.cpp
More file actions
62 lines (55 loc) · 1.33 KB
/
1044.cpp
File metadata and controls
62 lines (55 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*************************************************************************
> File Name: 1044.cpp
> Author: dulun
> Mail: [email protected]
> Created Time: 2016年03月06日 星期日 11时32分05秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define LL long long
using namespace std;
const int N = 30086;
int a[N];
int dp[N];
int main()
{
int n = 0;
while(~scanf("%d", &a[n++])); n--;
// cin>>n;
// for(int i = 0; i < n; i++) scanf("%d", &a[i]);
int len = 1;
dp[0] = a[0];
for(int i = 1; i < n; i++)
{
int left = 0, right = len;
while(left < right)
{
int m = (left+right) / 2;
if(dp[m] < a[i]) right = m;
else left = m+1;
}
dp[left] = a[i];
if(left == len) len++;
}
cout<<len<<endl;
len = 1;
memset(dp, 0, sizeof(dp));
dp[0] = a[0];
for(int i = 1; i < n; i++)
{
int left = 0, right = len;
while(left < right)
{
int m = (left+right) / 2;
if(dp[m] > a[i]) right = m;
else left = m+1;
}
dp[left] = a[i];
if(left == len) len++;
}
cout<<len<<endl;
return 0;
}