题目:
思路分析:
思路嘛:
把车放入到小于该轨道的最小序列号
但这不是最优解 而是贪心的选取轨道应该是最接近该序列号的轨道!
选取的时候既可以用二分选取也可以用set中lower——bound方法!
代码实现:
int main(){
int n;
cin>>n;
set<int>st;
while (n--) {
int x;
cin>>x;
set<int>::iterator it=st.lower_bound(x);
if(it!=st.end()){
st.erase(it);
st.insert(x);
}
else {
st.insert(x);
}
}
cout<<st.size()<<endl;
}