顺风第二题 最长增序序列的变体 AC代码
#include<iostream> #include<algorithm> #include<vector> using namespace std; int f[300005]; int main(){ int n; cin>>n; vector<int> num(n, 0); for(int i = 0; i < n; i++) cin>>num[i]; int len = 0; for(int i = 0; i < n; i++){ if(len == 0) f[len++] = num[i]; else if(num[i]>=f[len-1]) f[len++] = num[i]; else { int k = upper_bound(f,f+len,num[i])-f; f[k] = num[i]; } } cout<<len; }
#笔试题目##顺丰科技#