Little_x_starTYJ @ 2024-10-09 15:23:03
首先 Sub 1 全过,然后 Sub 2 WA了。
#include <bits/stdc++.h>
using namespace std;
int dp[5010], a[5010], ans;
int main() {
ios::sync_with_stdio(false);
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++) {
dp[i] = 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;
return 0;
}
by xyztapeplayer @ 2024-10-09 15:25:44
if后面加个
else dp[i]=dp[j];
by FChang @ 2024-10-09 15:26:18
%%%
by Little_x_starTYJ @ 2024-10-09 15:27:12
@Bed_War 只过一个点了。
by xyztapeplayer @ 2024-10-09 15:29:11
@Little_x_starTYJ 搞错了,if后面加个 else dp[i]=max(dp[i],dp[j]);
by Little_x_starTYJ @ 2024-10-09 15:30:27
@Bed_War 同上。
by Nazale_ @ 2024-10-09 15:32:44
ber哥们,它让求的最长严格上升子序列啊
by Duboy @ 2024-10-09 15:33:55
把15行的<=改成<试试
by Duboy @ 2024-10-09 15:34:44
@Duboy 是>=改>点错了
by Little_x_starTYJ @ 2024-10-09 15:34:57
@Cxs_Lg 题目没说严格上升啊。
by Little_x_starTYJ @ 2024-10-09 15:35:40
已关。