#K68367. Two Sum Indices Problem
Two Sum Indices Problem
Two Sum Indices Problem
In this problem, you are given an array of integers and a target value . Your task is to determine whether there exist two distinct indices and (1-based indexing) such that the sum of the elements at these indices equals , i.e., $$a_i + a_j = k.$$ If such a pair exists, output "YES" followed by the two indices. Otherwise, output "NO" and -1 for both indices.
Note that if there are multiple solutions, you may output any one of them.
inputFormat
The input is given via standard input. The first line contains two integers and , where is the number of elements in the array, and is the target sum. The second line contains space-separated integers representing the array elements.
outputFormat
Print a single line to standard output. If a valid pair is found, print "YES" followed by the two 1-based indices separated by spaces. If no such pair exists, print "NO -1 -1".## sample
5 9
1 7 5 3 2
YES 2 5