QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 512 MB Points totaux : 100

#16962. 守财奴

Statistiques

在某所非典型大学里,食堂将在 $n$ 天后举行开业典礼。在关闭的食堂门前,挂着一块写有数字的牌子——表示距离开业还有多少天。

在这 $n$ 天中,食堂经理知道每天有哪些人会来到大学并看到这块牌子。经理必须每天选择一块写有数字的牌子,使得每个来到大学的人在不同日期看到牌子上的数字时,都觉得这个数字是递减的。

经理是一个典型的吝啬鬼,他想花尽可能少的钱,因此希望订购最少数量的不同数字的牌子。你的任务是帮助经理求出这个最小值。

考虑第一个样例:第 1 个人在第 1、2、5 天来,第 2 个人在第 2、3、4 天来。经理可以只订购四块写有数字 1、2、3、4 的牌子,在第 5 天和第 4 天放置数字 1,在第 3 天放置数字 2,在第 2 天放置数字 3,在第 1 天放置数字 4。这样,第 1 个人看到的数字依次为 4、2、1,第 2 个人看到的数字依次为 3、2、1。

输入格式

输入的第一行包含一个整数 $n$——距离食堂开业的总天数。

接下来的 $n$ 行包含每天的描述。每行的描述以一个正整数 $k$ 开始——当天来到大学的人数。紧接着是 $k$ 个互不相同的整数——这些人的编号。

所有天数的 $k$ 之和不超过 $10^5$。人的编号为正整数且不超过 $10^5$。

输出格式

输出一个整数——需要订购的不同数字牌子的最少数量。

样例

输入样例 1

5
1 1
2 1 2
1 2
1 2
1 1

输出样例 1

4

输入样例 2

5
1 1
1 1
1 1
1 1
1 1

输出样例 2

5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.