QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 64 MB 總分: 100

#12254. 梯子

统计

你有 $n$ 根长度分别为 $d_1, d_2, \dots, d_n$ 的木棍。要建造一个梯子,你需要 $k + 2$ 根木棍:其中两根长度为 $x$,另外 $k$ 根长度为 $y$。你可以缩短已有的木棍,但不能将一根木棍分成两根。请问你能否造出一个梯子?

输入格式

输入的第一行包含一个整数 $z$,表示测试用例的数量。接下来是各测试用例的描述。

每个测试用例包含四个整数 $n, k, x, y$ ($1 \le n \le 10^5, 0 \le k \le 10^5, 1 \le x, y \le 10^9$),随后是 $n$ 个整数 $d_1, d_2, \dots, d_n$ ($1 \le d_i \le 10^9$)。

输出格式

对于每个测试用例,如果可以造出梯子,输出一行包含单词 “YES”,否则输出 “NO”。

样例

样例输入 1

2
8 3 5 2
1 1 1 2 3 4 5 6
8 3 6 2
1 1 1 2 3 4 5 6

样例输出 1

YES
NO

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.