不用麻烦了,已经找到问题了
```cpp
int l = lower_bound(st+1,st+1+ans+1,p[i].w)-st;
```
这里有bug
改成
```cpp
int l = lower_bound(st,st+ans+1,p[i].w)-st;
```
就行了
by qpdk777 @ 2020-04-19 20:56:47
这一题不是DP嘛
by ZhangJiahao0918 @ 2020-04-19 20:57:37
@[ZhangJiahao0918](/user/279222) 贪心
by twelveZ @ 2020-04-19 21:06:20
@[code_universe](/user/107232)
可是我是这样写的啊qwq
```
#include<bits/stdc++.h>
using namespace std;
struct STICK{
int l=0;
int w=0;
};
int n=0;
int ans=0;
int dp[66666];
bool CMP(STICK x,STICK y){
if(x.l!=y.l){
return x.l>y.l;
}
return x.w>y.w;
}
STICK s[66666];
int main(){
memset(dp,0,sizeof(dp));
cin>>n;
for(int i=1;i<=n;i++){
cin>>s[i].l;
cin>>s[i].w;
}
sort(s+1,s+1+n,CMP);
for(int i=n;i>=1;i--){
for(int j=i+1;j<=n;j++){
if(s[i].l<s[j].l&&dp[i]<dp[j]+1){
dp[i]=dp[j]+1;
}
else{
if(s[i].w<s[j].w&&dp[i]<dp[j]+1){
dp[i]=dp[j]+1;
}
}
}
}
for(int i=1;i<=n;i++){
ans=max(ans,dp[i]);
}
cout<<ans+1<<endl;
return 0;
}
```
by ZhangJiahao0918 @ 2020-04-19 21:33:40
@[ZhangJiahao0918](/user/279222) 不需要dp,双降排序贪心
by twelveZ @ 2020-04-19 21:36:18