
貪心、資料結構
#include<bits/stdc++.h>
#define int long long
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
//declare
int n;
vector<int> v;
multiset<int> st;
//
signed main(){
fastio;
cin>>n;
for(int i=0;i<n;i++){
int x; cin>>x;
v.push_back(x);
}
for(int i=0;i<n;i++){
auto it = st.upper_bound(v[i]);
if(it == st.end()) st.insert(v[i]);
else st.erase(it), st.insert(v[i]);
}
cout<<st.size()<<"\n";
return 0;
}

發佈留言