3263.k-d-sequence

Time Limit: 1s Memory Limit: 256MB

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

You got hold of some sequence a, consisting of n integers. Your task is to find its longest contiguous subsegment, such that it is a good k-d sequence.

Input Format(From the terminal/stdin)

The first line contains three space-separated integers n,k,d (1 \le n \le 2 \cdot 105;0 \le k \le 2 \cdot 105;0 \le d \le 109). The second line contains n space-separated integers: a1,a2,...,an (-109 \le ai \le 109)- the actual sequence.

Output Format(To the terminal/stdout)

Print two space-separated integers l,r (1 \le l \le r \le n) show that sequence al,al+1,...,ar 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.

Sample Input

Copy
6 1 2
4 3 2 8 6 2
 · · \n
 · · · · · \n

Sample Output

Copy
3 5
 · \n

Hints

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.

Submit

请先 登录

© 2025 FAQs