#C11819. Find Pair with Given Difference

    ID: 41177 Type: Default 1000ms 256MiB

Find Pair with Given Difference

Find Pair with Given Difference

You are given a list of N integers and an integer k. Your task is to find two distinct indices i and j such that the absolute difference between arr[i] and arr[j] is exactly \(k\), i.e., \(|arr[i] - arr[j]| = k\).

If such a pair exists, output the indices in the order they are found separated by a space. Otherwise, print -1. If multiple answers exist, any valid pair is acceptable.

Note: The indices are 0-based.

inputFormat

The first line contains two integers: N (the number of elements in the array) and k, separated by a space.

The second line contains N integers separated by spaces.

outputFormat

If a pair of indices exists that satisfies the condition \(|arr[i] - arr[j]| = k\), print the two indices separated by a space. Otherwise, print -1.

## sample
5 5
10 15 3 7 8
0 1