#1对了,其他全WA,求助

B3637 最长上升子序列

damuzhi @ 2024-07-02 09:15:20

#include <bits/stdc++.h>

using namespace std;

    int a[100010];
    int f[100010];
    int n;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= n; i++)
        f[i] = 1;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= i; j++)
            if(a[j] < a[i])
                f[i] = max(a[j]+1,a[i]);
    int ans = -1e9;
    for(int i = 1; i <= n; i++)
        ans = max(ans,f[i]);
    cout << ans << '\n';
    return 0;
}

by damuzhi @ 2024-07-02 09:17:00

发现了,f的提到公式写错了,已AC,此贴结


|