QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 10

#6063. 序列 [A]

Statistics

在本题中,我们考虑长度为 $n$ 的整数序列。两个序列 $A = (a_1, a_2, \dots, a_n)$ 和 $B = (b_1, b_2, \dots, b_n)$ 之间的距离定义为: $$d(A, B) = |a_1 - b_1| + |a_2 - b_2| + \dots + |a_n - b_n|$$ 其中 $|x|$ 表示 $x$ 的绝对值。

给定 $k$ 个序列 $A_1, A_2, \dots, A_k$,你的任务是找到它们的中心,即一个整数序列 $B$,使得 $$\max\{d(A_i, B) : i = 1, 2, \dots, k\}$$ 的值尽可能小。

输入格式

输入的第一行包含两个整数 $n$ 和 $k$ ($2 \le n \le 100\,000$, $2 \le k \le 5$)。接下来的 $k$ 行,每行包含一个序列的描述,由 $n$ 个绝对值不超过 $10^9$ 的整数组成。

在总分 1 分的测试点中,满足 $k \le 2$。在总分 3 分的测试点中,满足 $k \le 3$。在总分 6 分的测试点中,满足 $k \le 4$。

输出格式

输出一行,包含 $n$ 个由空格分隔的整数,描述输入序列的中心。如果存在多个正确的答案,程序可以输出其中任意一个。

样例

输入 1

5 3
1 -1 2 -1 2
1 2 2 1 2
2 2 -1 1 1

输出 1

1 2 2 1 2

说明 1

结果序列与各输入序列的距离分别为 5, 0 和 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.