-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abc8936
commit 4ba064b
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
using ll = long long ; | ||
// #define si size() | ||
#define pb push_back | ||
|
||
|
||
int main() { | ||
ios_base::sync_with_stdio(false); | ||
cin.tie(NULL); | ||
int n; | ||
cin>>n; | ||
vector<int> v; | ||
for(int i=0;i<n;i++){ | ||
int t; | ||
cin>>t; | ||
int hi=v.size(); | ||
int lo=0; | ||
while(lo<hi){ | ||
int mid =(hi+lo)/2; | ||
if(v[mid]<=t){ | ||
lo = mid+1; | ||
continue; | ||
}else{ | ||
hi=mid; | ||
} | ||
}if(lo==v.size()){ | ||
v.pb(t); | ||
}else{ | ||
v[lo]=t; | ||
} | ||
}cout<<v.size(); | ||
return 0; | ||
} |