TopCoder

User's AC Ratio

100.0% (3/3)

Submission's AC Ratio

75.0% (6/8)

Tags

Description

有 $n$ 個相異的整數 $a_1, a_2, \dots, a_n$,由左向右取,並且數字必須遞增,設最大長度為 $L$(即 Longest Increasing Subsequence)。

試問在這 $n$ 個整數當中,最多能找到幾組數字不重覆使用的 Longest Increasing Subsequence?

例如,序列 $3\ 1\ 8\ 4\ 9\ 5$ 的 $L=3$,最多可選出 $2$ 組數字不重覆使用的 LIS:$(1,8,9)$, $(3,4,5)$。

Input Format

有多組測試資料,每組第一行為一個正整數 $n$ 表示數列長度,接下來有 $n$ 個數字照順序為 $a_1, a_2, \dots, a_n$。

當 $n=0$ 時結束。

  • $1 \leq n \leq 200$
  • $0 \leq a_i \leq 1000$
  • $a_i$ 皆相異
  • $\sum n \leq 2000$

Output Format

對於每組測試資料輸出兩個數字:$L$ 和數字不重覆的 LIS 組數。

Sample Input 1

6
3 1 8 4 9 5
6
3 1 8 4 9 5
0

Sample Output 1

3 2
3 2

Hints

Problem Source

Migrated from old NTUJ.

2025-02-17 修正與補強測資

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 2097152 65536
1 1000 2097152 65536
2 1000 2097152 65536
3 1000 2097152 65536
4 1000 2097152 65536
5 1000 2097152 65536
6 1000 2097152 65536
7 1000 2097152 65536
8 1000 2097152 65536
9 1000 2097152 65536
10 1000 2097152 65536
11 1000 2097152 65536
12 1000 2097152 65536