pages:
  • 1
Daneshvar Amrollahi SAYS

Hi. Can anyone tell me why this code is not working? I'm almost sure about my code. I'm using DP.

//Bismillah
#include<iostream>
#include<algorithm>
using namespace std;
#define FOR(i,begin,end) for (ll i=begin;i<=end;i++)
#define rep(i,t) for (ll i=0;i<t;i++)
int main()
{
    ios_base::sync_with_stdio(false);
    int n,t;
    cin>>t;
    while (t--)
    {
        cin>>n;
        int a[1200];
        FOR(i,1,n)
            cin>>a[i];
        int dp[1200];
        rep(i,1200)
            dp[i] = 1;
        FOR(i,1,n)
            FOR(j,1,i-1)
                if (a[j]<=a[i] && dp[i]<dp[j]+1)
                    dp[i] = dp[j]+1;
        sort(dp,dp+n+1);
        cout<<dp[n]<<endl;
    }
    return 0;
}
//Daneshvar Amrollahi