logo AlgoBeat OnlineJudge
登录 注册

#215209. [UOI 2024 II Stage] Sequence

内存限制:512 MiB 时间限制:1500 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Anton is under pressure --- he has to submit all the assignments. As often happens --- he cannot extend the deadline...

You are given a sequence of integers, and two integers and . You need to find the longest subsequence of the sequence such that (). Here, denotes the number of elements in the sequence . In other words, you need to select a subsequence such that the sum of any two adjacent numbers is not less than and not greater than .

A subsequence of an array is a sequence that can be obtained by deleting several (possibly none) elements from the original sequence.

输入格式

The first line contains three integers , , (, ).

The second line contains integers () --- the description of the sequence.

输出格式

Output a single integer --- the maximum length of such a subsequence .

样例

样例输入 1

5 2 6
1 3 4 2 5

样例输出 1

3

样例输入 2

2 1 1
1 1

样例输出 2

1

数据范围与提示

In the first example, you can select the subsequence . . .

You can also select .

Scoring

  • ( point): all are the same;
  • ( points): for all ;
  • ( points): ;
  • ( points): ;
  • ( points): ;
  • ( points): ;
  • ( points): ;
  • ( points): ;
  • ( points): ;
  • ( points): no additional constraints.