AT_agc078_b.L Robust IS

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a length-NN sequence of positive integers A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N) and non-negative integers X,YX,Y.

Find the maximum length MM of a subsequence B=(B1,B2,…,BM)B=(B_1,B_2,\ldots,B_M) of AA that satisfies both of the following conditions.

  • Bi≥Bi−1−XB_i\ge B_{i-1}-X holds for every integer ii satisfying 2≤i≤M2\le i\le M.
  • Bi≥Bi−2−(X+Y)B_i\ge B_{i-2}-(X+Y) holds for every integer ii satisfying 3≤i≤M3\le i\le M.

给定一个长度为 NN 的正整数序列 A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N),以及两个非负整数 X,YX,Y。

求满足以下两个条件的 AA 的子序列 B=(B1,B2,…,BM)B=(B_1,B_2,\ldots,B_M) 的最大长度 MM:

  • 对每个满足 2≤i≤M2\le i\le M 的整数 ii,均有 Bi≥Bi−1−XB_i\ge B_{i-1}-X;
  • 对每个满足 3≤i≤M3\le i\le M 的整数 ii,均有 Bi≥Bi−2−(X+Y)B_i\ge B_{i-2}-(X+Y)。

输入格式

The input is given from Standard Input in the following format:

NN XX YY
A1A_1 A2A_2 …\ldots ANA_N

输入从标准输入中按以下格式给出:

NN XX YY
A1A_1 A2A_2 …\ldots ANA_N

输出格式

Output the answer.

输出答案。

输入输出样例

  • 输入#1

    7 3 1
    8 6 3 7 5 2 6

    输出#1

    5
  • 输入#2

    5 0 0
    5 4 3 2 1

    输出#2

    1
  • 输入#3

    15 441943320 890669835
    693547414 783888993 702664735 345257171 73365711 320257375 683236857 951712144 151653382 210806164 439829968 987667432 978973992 565844495 621822141

    输出#3

    13

说明/提示

Sample 1 Explanation:
The subsequence (8,6,7,5,6)(8,6,7,5,6) satisfies the conditions. There is no subsequence of length 66 or greater that satisfies the conditions, so output 55.

Constraints

  • 1≤N≤5×1051\le N\le 5\times 10^5
  • 1≤Ai≤1091\le A_i\le 10^9
  • 0≤X,Y≤1090\le X,Y\le 10^9
  • All input values are integers.

样例 1 解释:
子序列 (8,6,7,5,6)(8,6,7,5,6) 满足条件。不存在长度为 66 或更大的满足条件的子序列,因此输出 55。

约束条件

  • 1≤N≤5×1051\le N\le 5\times 10^5
  • 1≤Ai≤1091\le A_i\le 10^9
  • 0≤X,Y≤1090\le X,Y\le 10^9
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页