提交时间:2023-04-13 21:57:30
运行 ID: 74603
#include<bits/stdc++.h> using namespace std; struct member{ int strong; int beauty; }; bool cmp(member a,member b){ return a.strong<b.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[i].strong!=a[j].strong) { dp[i]=max(dp[i],dp[j]+1); } } maxs=max(maxs,dp[i]); } cout<<maxs; return 0; }