#P6527. 4527 k-d-sequence

4527 k-d-sequence

Description

【题面翻译】

找一个最长的子区间使得该子区间加入至多 $k$ 个数以后,排序后是一个公差为 $d$ 的等差数列。
多个解输出 $l$ 最小的。

【输入格式】

The first line contains three space-separated integers $ n,k,d $ ( $ 1<=n<=2·10^{5}; 0<=k<=2·10^{5}; 0<=d<=10^{9} $ ). The second line contains $ n $ space-separated integers: $ a_{1},a_{2},...,a_{n} $ ( $ -10^{9}<=a_{i}<=10^{9} $ ) — the actual sequence.

【输出格式】

Print two space-separated integers $ l,r $ ( $ 1<=l<=r<=n $ ) show that sequence $ a_{l},a_{l+1},...,a_{r} $ is the longest subsegment that is a good $ k $ - $ d $ sequence.

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

【样例输入】

6 1 2
4 3 2 8 6 2

【样例输出】

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.