#K13226. Count Unique Pairs with Given Sum
Count Unique Pairs with Given Sum
Count Unique Pairs with Given Sum
Given an array of integers and an integer ( k ), your task is to determine the number of unique pairs ( (a, b) ) such that ( a + b = k ). A pair is considered unique if the two numbers forming the pair are distinct in value ordering (i.e. ( (a, b) ) is the same as ( (b, a) )).
The input will be provided from standard input and the answer must be printed to standard output.
inputFormat
The first line of input contains two integers ( n ) and ( k ), where ( n ) is the number of elements in the array and ( k ) is the target sum. The second line contains ( n ) space-separated integers representing the array elements.
outputFormat
Output a single integer representing the number of unique pairs that sum up to ( k ).## sample
5 6
1 2 3 4 3
2