#include <iostream>
using namespace std;
int N;
int arr[1001];
int dp[1002];
int maxcost = 0;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N;
for (int i = 1; i <= N; i++)
{
cin >> arr[i];
}
for (int i = N; i >= 1; i--)
{
int temp = 0;
int dtemp = 0;
for (int j = N + 1; j > i; j--)
{
if (arr[i] > arr[j])
{
temp = dp[j];
}
if (temp > dtemp)
{
dtemp = temp;
}
}
dp[i] = dtemp + 1;
if (dp[i] > maxcost)
{
maxcost = dp[i];
}
}
cout << maxcost << "\n";
return 0;
}
DP 관련 문제였다.
Baekjoon_Link 👈 Click here