QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 100

#3388. 屋里的负数人

Estadísticas

以下是一个供您娱乐的数学笑话: 两位数学家坐在房子外面的车里。两个人进入了房子。然后,观察到三个人从房子里走出来。其中一位数学家惊呼道:如果现在再进去一个人,房子就空了!

由于您缺乏幽默感,您需要编写一个程序来计算房子里最初必须有的最少人数。换句话说,给定一组人离开和进入房子的序列,输出在您开始跟踪之前,房子里必须有的最少人数。在编写完这个程序后,您的数学家朋友将离开您,以及他们的数学系,去创办一家专门从事讲笑话和跟踪的公司。

输入格式

输入的第一行包含一个整数 $T$,表示测试用例的数量。接下来的 $T$ 个测试用例,每个用例包含两部分:首先,一行包含一个整数 $M$。接着是 $M$ 行,每行包含两个用空间隔的整数 $P_1$ 和 $P_2$,其中第一个数表示进入房子的人数,第二个数表示离开房子的人数。注意,这是两个事件:首先 $P_1$ 个人进入房子,然后 $P_2$ 个人离开房子。

输出格式

输出在开始时房子里必须有的最少人数。

数据范围

  • $0 < T \le 50$
  • $0 < M \le 100$
  • $0 \le P_1, P_2 \le 1000$

样例

输入格式 1

1
3
3 5
3 4
1 0

输出格式 1

3

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.