#K54482. Count Unique Pairs Summing to Target

    ID: 29763 Type: Default 1000ms 256MiB

Count Unique Pairs Summing to Target

Count Unique Pairs Summing to Target

Given an array of integers and a target value \(T\), your task is to count the number of unique pairs \((a, b)\) in the array such that \(a + b = T\). A pair \((a, b)\) is considered the same as \((b, a)\), meaning the order does not matter. For instance, if the array is [1, 5, 7, -1, 5] and \(T = 6\), the unique pairs are \((1, 5)\) and \((7, -1)\), so the answer is 2.

Note: Each pair should be counted only once even if there are multiple occurrences of the same numbers.

inputFormat

The first line contains a single integer \(N\), the number of elements in the array.

The second line contains \(N\) space‐separated integers representing the array.

The third line contains an integer \(T\), the target sum.

outputFormat

Output a single integer representing the number of unique pairs in the array that add up to the target sum \(T\). The output should be printed to standard output.

## sample
5
1 5 7 -1 5
6
2