Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http: // . lightoj.com/article_show.php?article=1000&language=english&type=pdf
- #include<bits/stdc++.h>
- using namespace std;
- #define si(n) scanf("%d",&n)
- #define MAX 100005
- #define INF 0x3f3f3f3f
- int arr[MAX],t[MAX],l[MAX];
- int main()
- {
- //freopen("input.txt","r",stdin);
- int i,j,n;
- si(n);
- for(i=0;i<n;i++)si(arr[i]);
- memset(t,INF,sizeof(t));
- int mx_len=0;
- for(i=0;i<n;i++){
- int lo=0,hi=mx_len+1;
- while(hi-lo>1){
- int mid=(hi+lo)/2;
- if(t[mid]>=arr[i])hi=mid;
- else lo=mid;
- }
- lo++;
- t[lo]=arr[i];
- l[i]=lo;
- mx_len=max(mx_len,lo);
- }
- printf("%d\n",mx_len);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement