Skip to content

Commit

Permalink
Create towers.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mukulguptaiit committed Feb 6, 2025
1 parent abc8936 commit 4ba064b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions towers.cpp
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;
}

0 comments on commit 4ba064b

Please sign in to comment.