P28552 [洛谷] [HNOI2006] Pandora's Box
提高+
题目描述

Problem Description

Problem Description Image 1

Problem Description Image 2

Input Format

Input Format Image 1

Input Format Image 2

Output Format

Output a single line with a number \( t \), representing the length of the longest upgrade sequence.

Sample Input and Output

Input Sample #1

4
1  1
0
0  0
2  1
0
1  1
0  0
3  1
0
1  1
2  2
0  0
4  1
0
1  1
2  2
3  3
0  0

Output Sample #1

3

Input Sample #2

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

Output Sample #2

3

Notes/Hints

Notes/Hints Image

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 1 1 0 0 0 2 1 0 1 1 0 0 3 1 0 1 1 2 2 0 0 4 1 0 1 1 2 2 3 3 0 0
样例输出
3