40分求助
查看原帖
40分求助
1008172
duanzx楼主2023/7/21 20:33

这一题为什么错了,我试了好多样例都没发现错误。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vct vector
#define que queue
#define stk stack
#define sct struct
#define str string
#define N 114514
vct <int> a(N);
vct <int> dp(N);
bool cmp(ll x, ll y) {
	return x > y;
}

void solve() {
	
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	int ans = 1;
	for (int i = 2; i <= n; i ++) {	
		dp[1] = 1;
		for (int j = 1; j < i; j ++) {
			if (a[i] > a[j])
			dp[i] = max(dp[i], dp[j] + 1);
		}
		ans = max(ans, dp[i]);		
	}
	cout << ans;
}
2023/7/21 20:33
加载中...