CF407E.k-d-sequence

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

We'll call a sequence of integers a good kk - dd sequence if we can add to it at most kk numbers in such a way that after the sorting the sequence will be an arithmetic progression with difference dd .

You got hold of some sequence aa , consisting of nn integers. Your task is to find its longest contiguous subsegment, such that it is a good kk - dd sequence.

输入格式

The first line contains three space-separated integers n,k,dn,k,d ( 1<=n<=2105; 0<=k<=2105; 0<=d<=1091<=n<=2·10^{5}; 0<=k<=2·10^{5}; 0<=d<=10^{9} ). The second line contains nn space-separated integers: a1,a2,...,ana_{1},a_{2},...,a_{n} ( 109<=ai<=109-10^{9}<=a_{i}<=10^{9} ) — the actual sequence.

输出格式

Print two space-separated integers l,rl,r ( 1<=l<=r<=n1<=l<=r<=n ) show that sequence al,al+1,...,ara_{l},a_{l+1},...,a_{r} is the longest subsegment that is a good kk - dd sequence.

If there are multiple optimal answers, print the one with the minimum value of ll .

输入输出样例

  • 输入#1

    6 1 2
    4 3 2 8 6 2
    

    输出#1

    3 5
    

说明/提示

In the first test sample the answer is the subsegment consisting of numbers 2, 8, 6 — after adding number 4 and sorting it becomes sequence 2, 4, 6, 8 — the arithmetic progression with difference 2.

首页