QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 2048 MB 總分: 100

#8247. ICPC 队伍组建

统计

Vi 是她所在大学 ICPC 组织的教练,正在为即将到来的区域赛组建队伍。他们最近参加了北美资格赛(NAQ),Vi 正利用比赛结果以及每个人的偏好,尽可能多地组建三人队伍去参加区域赛。

更具体地说,来自 Vi 大学有 $n$ 名选手参加了北美资格赛,每个人的排名都是从 $1$ 到 $n$ 之间唯一的整数。排名为 $r$ 的选手有两个参数 $a_r$ 和 $b_r$,其中 $a_r \le r \le b_r$,这表示他们的两名队友的排名必须在 $[a_r, b_r]$ 范围内(包含边界)。每支队伍必须恰好有三个人。

由于协作环境的缘故,Vi 注意到对于任意两名排名为 $i$ 和 $j$ 的选手,如果 $i < j$,则 $a_i \le a_j$ 且 $b_i \le b_j$。

计算 Vi 可以派往区域赛的最多队伍数量。

输入格式

第一行包含一个整数 $n$ ($3 \le n \le 50$),表示本地比赛的参赛人数。

接下来的 $n$ 行,每行包含两个整数 $a_r$ 和 $b_r$ ($a_r \le r \le b_r$),其中 $r$ 是选手的排名。这些是该选手可以组队的队友排名范围。选手按排名顺序给出,从 $1$ 到 $n$。如果 $i < j$,则 $a_i \le a_j$ 且 $b_i \le b_j$。

输出格式

输出一个整数,表示 Vi 可以派往区域赛的最多队伍数量。

样例

样例输入 1

6
1 2
1 2
2 5
2 6
2 6
5 6

样例输出 1

1

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.