提交时间:2023-04-13 13:42:44

运行 ID: 74429

#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; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i].strong>>a[i].beauty; } sort(a+1,a+n+1,cmp); int maxs=-1; for(int i=1;i<=n;i++) { dp[i]=1; for(int j=1;j<i;j++) { if((a[j].beauty<a[i].beauty)&&(a[j].strong!=a[i].strong)) { dp[i]=max(dp[i],dp[j]+1); } } maxs=max(maxs,dp[i]); } cout<<maxs; return 0; }