QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 32 MB Total points: 100

#17021. Mali

Statistics

Mirko 和 Slavko 正在玩一个新游戏。又是他们。Slavko 在每一轮开始时会给 Mirko 两个数 $A$ 和 $B$,它们都小于 $100$。然后 Mirko 必须为 Slavko 解决以下任务:如何将所有给定的 $A$ 数与所有给定的 $B$ 数进行两两配对,使得这些配对的和的最大值尽可能小。

换句话说,如果在之前的回合中 Slavko 给出的数分别是 $a_1, a_2, a_3 \dots a_n$ 和 $b_1, b_2, b_3 \dots b_n$,请确定 $n$ 个配对 $(a_i, b_j)$,使得 $A$ 序列中的每个数恰好被使用一次,$B$ 序列中的每个数也恰好被使用一次,并且所有和 $a_i + b_j$ 的最大值最小。

输入格式

输入的第一行包含一个整数 $N$ ($1 \le N \le 100\,000$),表示回合数。

接下来的 $N$ 行,每行包含两个整数 $A$ 和 $B$ ($1 \le A, B \le 100$),表示 Slavko 在该回合中给出的数字。

输出格式

输出包含 $N$ 行,每回合一行。每行应包含该回合最小的最大配对和。

子任务

对于 $50\%$ 的测试数据,满足 $N \le 200$。

样例

输入样例 1

3
2 8
3 1
1 4

输出样例 1

10
10
9

输入样例 2

3
1 1
2 2
3 3

输出样例 2

2
3
4

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.