#C8494. Longest Increasing Subsequence

    ID: 52482 Type: Default 1000ms 256MiB

Longest Increasing Subsequence

Longest Increasing Subsequence

Given a sequence of integers, your task is to compute the length of the longest strictly increasing subsequence (LIS). A subsequence is obtained by deleting some elements (or none) from the original sequence without changing the order of the remaining elements. The subsequence must be strictly increasing, meaning each element is greater than the previous one.

The problem can be solved efficiently using a dynamic programming approach. The answer should be printed as a single integer on a single line.

inputFormat

The input is provided via standard input and consists of two lines:

  • The first line contains an integer N, representing the number of elements in the sequence.
  • The second line contains N space-separated integers representing the sequence. If N is 0, the second line will be empty.

outputFormat

Output a single integer to standard output representing the length of the longest strictly increasing subsequence of the given sequence.

## sample
8
10 22 9 33 21 50 41 60
5