#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char** argv)
{
    int n;
    cin >> n;
    vector<int> arr(n);
    vector<int> dp(n, 1);
    
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    int result = 1;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
           if (arr[i] < arr[j]) {
               dp[j] = max(dp[j], dp[i] + 1);
               result = max(result, dp[j]);
           }
        }
    }
    cout << result << endl;
    
    return 0;
}
시간 복잡도 : n^2
n이 3000이라 제곱이여도 가능
'알고리즘' 카테고리의 다른 글
| 프로그래머스 - 게임 맵 최단거리 (c++) (0) | 2025.02.23 | 
|---|---|
| Lv. 3 나무 섭지 - C++ (0) | 2024.12.10 | 
| Lv. 3 함께하는 효도 - C++ (0) | 2024.12.10 | 
| Lv. 3 자동차 테스트 (0) | 2024.12.10 | 
| [Algorithm] Introduction to Algorithms 개정 3판 답지 (0) | 2024.02.18 |