一开始没想到是dp真是罪过
见状态转移想dp
一见到能用dfs做的想dp
int solution(int n, int H, int A, vector<int> h, vector<int> a) {
int ans=0;
vector<int>dp(n,0xc0c0c0c0);
for(int i=0;i<n;i++){
if(h[i]<H&&a[i]<A)dp[i]=1;
}
for (int now = 0; now < n; now++) {
for (int pre = 0; pre < n; pre++) {
if (now == pre) continue;
if (h[pre] > h[now] && a[pre] > a[now]) {
dp[now] = max(dp[now], dp[pre] + 1);
}
}
ans = max(ans, dp[now]);
//cout<<"!"<<ans<<endl;
}
return ans;
}