上面的wa了下面的re了为什么??
查看原帖
上面的wa了下面的re了为什么??
1303247
wxhwym_zd_wat楼主2024/7/4 11:03
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 5010;
typedef struct city{
    int x,y;
};
bool cmp(city a,city b){
    return a.x>b.x;
}
void solve(){
    int n;
    cin >> n;
    city a[N];
    int l[N],r[N];
    for(int i=1;i<=n;i++){
        cin >> a[i].x >> a[i].y; 
    }
    sort(a+1,a+n+1,cmp);
    int mx=0;
    for(int i=1;i<=n;i++){
        l[i]=1;
        for(int j=1;j<i;j++){ 
            if(a[i].y>a[j].y) l[i]=max(l[i],l[j]+1);
        }
        mx=max(l[i],mx);
    }
    cout << mx << '\n';
}
int main()
{
    solve();
    return 0;
}
2024/7/4 11:03
加载中...