[BOJ 9702] LIS

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 128M

Problem type
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

Mr. C is interested with Longest Increasing Subsequence problem. Given a sequence S = s1, s2, …, sN. The Longest Increasing Subsequence is the subsequence L = l1, l2, …, lk of S such that l1 < l2 < … < lk. </p>

Given a sequence S, find the total length of LIS of every consecutive subsequence (subsequence which elements are consecutive in the original sequence) of S with non zero length!

입력 형식

The first line of input consists of an integer T denotes the number of cases. It is followed by T blocks, each representing a case.</p>

The first line of each case contains an integers: N (1 ≤ N ≤ 500), the length of S.

The next N lines each consists of an integer si (1 ≤ si ≤ N) denoting the i-th element of S. Each element of S is unique.

출력 형식

Output consists of T lines, each describes the solution for each case with the same order as in input.</p>

Each case consists of a single line with the format “Case #i: S”, where i represents the case number and S represents the total length of LIS of every consecutive subsequence of S.

예제 입력

1
3
3
1
2

예제 출력

Case #1: 8

Comments

There are no comments at the moment.