为什么求最长上升子序列时,把lower_bound换成upper_bound就出错了啊
#include <iostream>
#include <algorithm>
using namespace std;
int num[100020];
int st1[100020], st2[100020];
int cnt = 0;
int top1 = 1;
int top2 = 1;
int main(){
while(cin>>num[++cnt]);
cnt -= 1;
st1[1] = num[1];
st2[1] = num[1];
for(int i = 2; i <= cnt; i++){
if(num[i] <= st1[top1]){
st1[++top1] = num[i];
}
else{
int k = upper_bound(st1 + 1, st1 + 1 + top1, num[i], greater<int>() ) - st1;
st1[k] = num[i];
}
if(num[i] > st2[top2]){
st2[++top2] = num[i];
}
else{
int k = upper_bound(st2 + 1, st2 + 1 + top2, num[i]) - st2;
st2[k] = num[i];
}
}
cout<<top1<<endl<<top2;
return 0;
}