#abc327f. F - Apples
F - Apples
Score : points
问题描述
在数轴上排列着苹果树,共有 个苹果从树上落下。具体来说,对于每个 ,第 个苹果在时刻 落在坐标点 。
高桥有一个篮子,其耐久度为 ,长度为 ,他可以精确地执行一次以下操作:
选择正整数 和 。他在时刻 将篮子设置在范围 内,并在时刻 收回篮子。在这段时间内,篮子覆盖范围内落下的所有苹果都会被他收集到。
一旦篮子被设置好后就不能移动,而且一旦收回篮子后就不能再次设置。
请找出高桥最多可以获得的苹果数量。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are apple trees lined up on a number line, and apples fall from the trees.
Specifically, for each , an apple falls at coordinate at time .
Takahashi has a basket with durability and length , and he can take the following action exactly once.
Choose positive integers and . He sets up the basket to cover the range at time , and retrieves it at time . He gets all the apples that fell into the range covered by the basket between the time it was set up and the time it was retrieved.
He cannot move the basket once it has been set up, nor can he set it up again once it has been retrieved.
Find the maximum number of apples that he can get.
Constraints
- All pairs are different.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the maximum number of apples that Takahashi can get.
Sample Input 1
8 4 3
1 1
3 4
6 4
5 2
4 2
4 3
5 5
7 3
Sample Output 1
5
If Takahashi chooses and , he will set up the basket to cover the range from time to . Then, he gets the following five apples:
- The apple that falls at coordinate at time
- The apple that falls at coordinate at time
- The apple that falls at coordinate at time
- The apple that falls at coordinate at time
- The apple that falls at coordinate at time
There is no way to get six or more apples, so print .
update @ 2024/3/10 01:51:45