QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 1024 MB 満点: 100

#9223. 数据确定

統計

曾经有一位非常严谨的科学家,他决定一劳永逸地回答关于生命、宇宙以及一切的终极问题。他从理论推导开始,最终得出结论:答案是一个正整数,且等于 $m$。然而,这些推导基于许多关于生命、宇宙和一切的不确定假设。理论推导应当得到实验证据的支持!

科学家设计了一个特殊的实验,其中包含各种测量误差。他进行了 $n$ 次实验,第 $i$ 次实验的结果为数字 $a_i$。在他的科学工作中,他计划选取恰好 $k$ 个实验的数据,且它们的统计中位数(median)必须恰好为 $m$,以证实他的理论。

请验证他是否能实现目标。编写一个程序,给定所有 $n$ 次实验的结果,判断是否可以从中选取 $k$ 个实验,使得它们的中位数为 $m$。

输入格式

输入的第一行包含一个整数 $t$ ($1 \le t \le 10\,000$),表示需要考虑的独立场景数量。每个场景由两行描述。

每个场景的第一行包含三个整数 $n, k$ 和 $m$ ($1 \le k \le n \le 200\,000, 1 \le m \le 10^9$),分别表示进行的实验次数、科学工作所需的实验数量以及期望的中位数。第二行包含 $n$ 个整数 $a_1, \dots, a_n$ ($1 \le a_i \le 10^9$),表示实验结果。

所有测试用例中 $n$ 的总和不超过 $200\,000$。

输出格式

输出应包含 $t$ 行,为每个场景提供答案。如果可以在第 $i$ 个场景中选取合适的 $k$ 个实验,则第 $i$ 行应输出一个单词 TAK,否则输出 NIE

样例

输入 1

3
6 4 42
41 43 41 57 41 42
4 2 4
1 2 5 8
7 5 57
101 2 42 5 57 7 13

输出 1

TAK
NIE
NIE

说明

在第一个场景中,你可以选择结果为 $(41, 43, 41, 57)$ 的实验;排序后得到序列 $(41, 41, 43, 57)$,其中两个中间元素的算术平均值为 $\frac{43+41}{2} = 42$。

在第二个场景中,无法选择一对元素使得中位数为 $4$。例如:

  • 序列 $(2, 5)$ 的中位数为 $\frac{2+5}{2} = 3.5$,太小了。
  • 另一方面,序列 $(1, 8)$ 的中位数为 $\frac{1+8}{2} = 4.5$,太大了。

*序列的中位数是指排序后的中间元素。如果序列长度为偶数,则为两个中间元素的算术平均值。例如,序列 $(9, 7, 3, 4, 5)$ 的中位数是 $5$,序列 $(3, 1, 6, 6)$ 的中位数是 $\frac{3+6}{2} = 4.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.