为什么RE(大佬求调)
  • 板块学术版
  • 楼主LHY2013
  • 当前回复8
  • 已保存回复8
  • 发布时间2025/2/7 16:19
  • 上次更新2025/2/7 17:09:44
查看原帖
为什么RE(大佬求调)
1429177
LHY2013楼主2025/2/7 16:19
#include<bits/stdc++.h>
using namespace std;
string ikun="woshixiaohezi";//我才是真ikun
const int maxn=1e6+10;
long long n,dp[maxn];
struct st{
    long long h,w;
};
st a[maxn];
bool cmp(st x,st y){
    if(x.h!=y.h){
        return x.h<y.h;
    }else{
        return x.w<y.w;
    }
}
long long f(long long l,long long r,long long ans,long long step){
    if(dp[step]!=0)return dp[step];
    if(step==n+1)return ans;
    if(a[step].h>l&&a[step].w>r)dp[step]=max(dp[step],max(f(l,r,ans,step+1),f(a[step].h,a[step].w,ans+1,step+1)));
    else dp[step]=max(dp[step],f(l,r,ans,step+1));
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie();
std::cout.tie();
cin>>n;
for(int i=1;i<=n;i++){
    cin>>a[i].h>>a[i].w;
}
sort(a+1,a+1+n,cmp);
f(0,0,0,2);
f(a[1].w,a[1].h,1,2);
cout<<dp[n];
return 0;
}
2025/2/7 16:19
加载中...