@[preqzhor](/space/show?uid=135065) wide 和 length 双降排序
by ⚡小林孑⚡ @ 2019-10-14 22:27:42
@[preqzhor](/space/show?uid=135065)
我的代码
```cpp
#include<iostream>
#include<algorithm>
using namespace std;
int n;
struct note{
int l,w;
}a[5005];
bool use[5005];
bool cmp(note x,note y){
if(x.l==y.l) return x.w>y.w;
else return x.l>y.l;
}
int ans=0,tot=0;
int main(){
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i].l>>a[i].w;
sort(a+1,a+n+1,cmp);
while(tot<n){
int st;
for(st=1;use[st];st++);
int L=a[st].l,W=a[st].w;
ans++;tot++;use[st]=1;
for(int i=st+1;i<=n;i++)
if(a[i].l<=L&&a[i].w<=W&&use[i]==0){
use[i]=1;tot++;L=a[i].l;W=a[i].w;
}
}
cout<<ans<<endl;
}
```
by ⚡小林孑⚡ @ 2019-10-14 23:07:08
@[脱发自动机](/space/show?uid=119959) 谢谢dalaoQWQ
by preqzhor @ 2019-10-14 23:08:07
@[preqzhor](/space/show?uid=135065) 本题贪心,双降序排序,能取则取
by ⚡小林孑⚡ @ 2019-10-14 23:13:05