提交时间:2023-04-13 13:54:27
运行 ID: 74478
#include<bits/stdc++.h> #define int long long using namespace std; struct member{ int strong; int beauty; }; bool cmp(member a,member b){ return a.strong<a.strong; } member a[100001]; int dp[100001]; signed main(){ int n,i,j; cin>>n; for(i=1;i<=n;i++){ cin>>a[i].strong>>a[i].beauty; } sort(a+1,a+n+1,cmp); int maxs=0; for(i=1;i<=n;i++) { dp[i]=1; for(j=1;j<i;j++) { if((a[j].beauty>a[i].beauty)) { dp[i]=max(dp[i],dp[j]+1); } } maxs=max(maxs,dp[i]); } cout<<maxs; return 0; }