#C5965. Find Pair with Target Sum
Find Pair with Target Sum
Find Pair with Target Sum
You are given an array of integers representing the prices of items in a store and an integer target value \(T\). Your task is to find two distinct indices \(i\) and \(j\) (0-indexed) such that the sum of the prices at these indices is exactly equal to \(T\). If there are multiple valid pairs, return the first one found based on the order of evaluation. If no such pair exists, output -1.
Example:
Input: 4 2 7 11 15 9</p>Output: 0 1
Use efficient algorithms to handle large input sizes.
inputFormat
The input is read from standard input (stdin) and consists of three lines:
- The first line contains an integer \(n\), the number of items.
- The second line contains \(n\) space-separated integers representing the list of prices.
- The third line contains a single integer representing the target sum \(T\).
outputFormat
If a valid pair of indices exists, output the two indices (0-indexed) separated by a space on a single line. If no such pair exists, output -1.
## sample4
2 7 11 15
9
0 1
</p>