#K34332. Building the Longest Increasing String

    ID: 25286 Type: Default 1000ms 256MiB

Building the Longest Increasing String

Building the Longest Increasing String

You are given a series of string pieces, each represented by its length. A cat wants to build the longest possible string by attaching pieces one after another. However, the cat can only attach a piece if its length is strictly greater than the length of the piece it just attached.

Your task is to compute the maximum number of pieces the cat can attach, which is equivalent to finding the length of the longest increasing subsequence of the given list of integers.

Note: If there are no pieces, the result should be 0.

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  1. The first line contains an integer n denoting the number of string pieces.
  2. The second line contains n space-separated integers representing the lengths of the pieces.

If n is 0, then there will be no pieces given.

outputFormat

Output a single integer representing the maximum number of pieces that can be attached in strictly increasing order.

## sample
5
1 3 5 4 7
4