提交时间:2023-04-13 13:37:08
运行 ID: 74400
#include<bits/stdc++.h> using namespace std; struct member{ int strong; int beauty; }; bool cmp(member a,member b){ return a.strong<a.strong; } member a[10001]; int dp[10001]; int 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; }