题目描述
Problem Description
On a coastal area, there are $n$ lighthouses numbered from $1$ to $n$. This coast can be considered as a number line, where each lighthouse is a point on this line. The position of the $i$-th lighthouse on the number line is $x_i$, and there can be at most one lighthouse at each position. These $n$ lighthouses are arranged in ascending order of their positions, i.e., $x_i < x_{i+1}$ for $1 \le i < n$. Currently, there are exactly $n$ tourists waiting in line to enter the coast, with the $i$-th tourist intending to visit the $i$-th lighthouse.
For safety reasons, each lighthouse with a tourist must be illuminated. However, due to energy limitations on the coast, at most $t$ lighthouses can be lit. Each lighthouse has an illumination range of $q$. When the light on a lighthouse is turned on, all positions within a distance of $q$ from it on the coast will be illuminated (i.e., all points in the set $\{x \mid \lvert x-x_i \rvert \le q\}$ will be illuminated).
As the manager of the coastal tourism bureau, you need to decide which tourists can enter the coast. Your decision must meet the following requirements:
- Ensure safety first, i.e., find a lighting scheme such that every lighthouse with a tourist is illuminated;
- Ensure the first-come-first-served principle, where tourists at the front of the queue are given priority to enter the coast. If a tourist cannot enter the coast, then no tourists behind him in the queue can enter;
- Ensure the pursuit of profit, i.e., sell as many tickets as possible, meaning to allow as many tourists as possible to enter the coast.
After careful calculation, you determine the final number of tourists who can enter the coast.
Input Format
The first line contains two integers $n, t, q$, representing the number of lighthouses, the maximum number of lighthouses that can be lit, and the illumination range, respectively.
The second line contains $n$ integers, where the $i$-th integer $x_i$ represents the coordinate of the $i$-th lighthouse.
Output Format
Output a single integer, representing the number of tourists who can finally enter the coast.
Sample Input and Output
Sample Input #1
3 1 2
1 3 6
Sample Output #1
2
Sample Input #2
3 1 3
1 3 6
Sample Output #2
3
Notes/Hints
[Sample Explanation 1]
Allow the first two tourists to enter the coast and light up the first lighthouse. It can be proven that there is no legal scheme with more tourists.
[Sample Explanation 2]
Allow all three tourists to enter the coast and light up the second lighthouse. It can be proven that there is no legal scheme with more tourists.
[Subtasks]
| Subtask Number | $n \le$ | $t \le$ | $q \le$ | Score |
|---|---|---|---|---|
| 1 | $100$ | $100$ | $10^9$ | 20 |
| 2 | $10^3$ | $10^3$ | $10^9$ | 20 |
| 3 | $10^4$ | $10^4$ | $10^9$ | 20 |
| 4 | $10^5$ | $10^5$ | $10^9$ | 20 |
| 5 | $7.5 \times 10^6$ | $7.5 \times 10^6$ | $10^9$ | 20 |
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分