#K92042. Longest Strictly Decreasing Subsequence

    ID: 38109 Type: Default 1000ms 256MiB

Longest Strictly Decreasing Subsequence

Longest Strictly Decreasing Subsequence

You are given a list of integers. Your task is to determine the length of the longest strictly decreasing subsequence in the list. A subsequence is a sequence that can be derived from the list by deleting some or no elements without changing the order of the remaining elements.

Formally, given an array \(a_1, a_2, \dots, a_n\), you need to find the maximum \(k\) such that there exists indices \(i_1 < i_2 < \cdots < i_k\) that satisfy \(a_{i_1} > a_{i_2} > \cdots > a_{i_k}\). The dynamic programming formulation can be expressed as:

\[ dp[i] = \max_{0 \leq j a[i]}(dp[j]) + 1 \]

If the list is empty, the answer is 0.

inputFormat

The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers.

outputFormat

Output a single integer, which is the length of the longest strictly decreasing subsequence of the given array.

## sample
6
5 3 4 8 6 7
2